From 703d77b627a73542be2223dbe957a178891ad829 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Fri, 15 Nov 2013 17:33:46 -0800 Subject: [PATCH] FK removal --- Changes | 2 ++ DBSchema.pm | 2 +- DBSchema/ForeignKey.pm | 11 ++++++----- DBSchema/Table.pm | 18 ++++++++++-------- debian/changelog | 10 ++++++++-- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Changes b/Changes index 38ae7bd..cb1af01 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,8 @@ Revision history for Perl module DBIx::DBSchema 0.44_01 not released - POD fixes from Xavier Guimard and Damyan Ivanov of the Debian Perl Group, closes: CPAN#82187 + - More foreign key support + + table alteration (removing foreign keys) 0.43 2013-11-04 14:58;32 PST - Incorporate CPAN::Changes::Spec-compliant Changes file from Neil Bowers diff --git a/DBSchema.pm b/DBSchema.pm index fef7c09..b9021db 100644 --- a/DBSchema.pm +++ b/DBSchema.pm @@ -8,7 +8,7 @@ use DBIx::DBSchema::Index; use DBIx::DBSchema::Column; use DBIx::DBSchema::ForeignKey; -our $VERSION = '0.44_01'; +our $VERSION = '0.44_02'; $VERSION = eval $VERSION; # modperlstyle: convert the string into a number our $DEBUG = 0; diff --git a/DBSchema/ForeignKey.pm b/DBSchema/ForeignKey.pm index c47286c..2dfc93a 100644 --- a/DBSchema/ForeignKey.pm +++ b/DBSchema/ForeignKey.pm @@ -2,7 +2,7 @@ package DBIx::DBSchema::ForeignKey; use strict; -our $VERSION = '0.1'; +our $VERSION = '0.11'; our $DEBUG = 0; =head1 NAME @@ -77,7 +77,7 @@ sub new { =item constraint [ CONSTRAINT_NAME ] -Returns or sets the foreign table name +Returns or sets the constraint name =cut @@ -203,8 +203,6 @@ sub on_update { } } - - =item sql_foreign_key Returns an SQL FOREIGN KEY statement. @@ -233,8 +231,11 @@ sub cmp { my( $self, $other ) = @_; $self->table eq $other->table - and $self->columns_sql eq $other->columns_sql + and $self->columns_sql eq $other->columns_sql and $self->references_sql eq $other->references_sql + and uc($self->match) eq uc($other->match) + and uc($self->on_delete) eq uc($other->on_delete) + and uc($self->on_update) eq uc($other->on_update) ; } diff --git a/DBSchema/Table.pm b/DBSchema/Table.pm index bf07f0b..d096a2e 100644 --- a/DBSchema/Table.pm +++ b/DBSchema/Table.pm @@ -5,9 +5,9 @@ use Carp; use DBIx::DBSchema::_util qw(_load_driver _dbh _parse_opt); use DBIx::DBSchema::Column 0.14; use DBIx::DBSchema::Index; -use DBIx::DBSchema::ForeignKey; +use DBIx::DBSchema::ForeignKey 0.11; -our $VERSION = '0.10'; +our $VERSION = '0.11'; our $DEBUG = 0; =head1 NAME @@ -701,10 +701,7 @@ sub sql_alter_constraints { my @at = (); - ### # foreign keys (add) - ### - foreach my $foreign_key ( $new->foreign_keys ) { next if grep $foreign_key->cmp($_), $self->foreign_keys; @@ -712,9 +709,14 @@ sub sql_alter_constraints { push @at, 'ADD '. $foreign_key->sql_foreign_key; } - ### - # XXX TODO foreign keys modify / drop - ### + #foreign keys (drop) + foreach my $foreign_key ( $self->foreign_keys ) { + + next if grep $foreign_key->cmp($_), $new->foreign_keys; + next unless $foreign_key->constraint; + + push @at, 'DROP CONSTRAINT '. $foreign_key->constraint; + } return () unless @at; ( diff --git a/debian/changelog b/debian/changelog index 9b3f227..d5564d3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,12 @@ -libdbix-dbschema-perl (0.43-1) unstable; urgency=low +libdbix-dbschema-perl (0.44~02-2) UNRELEASED; urgency=low - * new upstream release + * new upstream (test) release + + -- Ivan Kohler Fri, 15 Nov 2013 17:33:02 -0800 + +libdbix-dbschema-perl (0.43~02-1) unstable; urgency=low + + * new upstream (test) release -- Ivan Kohler Mon, 04 Nov 2013 14:59:03 -0800 -- 2.11.0