FK removal
authorIvan Kohler <ivan@freeside.biz>
Sat, 16 Nov 2013 01:33:46 +0000 (17:33 -0800)
committerIvan Kohler <ivan@freeside.biz>
Sat, 16 Nov 2013 01:33:46 +0000 (17:33 -0800)
Changes
DBSchema.pm
DBSchema/ForeignKey.pm
DBSchema/Table.pm
debian/changelog

diff --git a/Changes b/Changes
index 38ae7bd..cb1af01 100644 (file)
--- 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 <x.guimard@free.fr> and Damyan Ivanov
       <dmn@debian.org> 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
index fef7c09..b9021db 100644 (file)
@@ -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;
index c47286c..2dfc93a 100644 (file)
@@ -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)
   ;
 }
 
index bf07f0b..d096a2e 100644 (file)
@@ -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;
   (
index 9b3f227..d5564d3 100644 (file)
@@ -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 <ivan-debian@420.am>  Fri, 15 Nov 2013 17:33:02 -0800
+
+libdbix-dbschema-perl (0.43~02-1) unstable; urgency=low
+
+  * new upstream (test) release
 
  -- Ivan Kohler <ivan-debian@420.am>  Mon, 04 Nov 2013 14:59:03 -0800