From bc25221f7ffc6107a5ab25ede974b261e0b59e36 Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Mon, 4 Nov 2013 14:56:40 -0800 Subject: [PATCH] Create/alter tables before foreign key changes --- DBSchema/Table.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/DBSchema/Table.pm b/DBSchema/Table.pm index b150d30..bf07f0b 100644 --- a/DBSchema/Table.pm +++ b/DBSchema/Table.pm @@ -669,8 +669,9 @@ sub sql_alter_table { =item sql_alter_constraints PROTOTYPE_TABLE, [ DATABASE_HANDLE | DATA_SOURCE [ USERNAME PASSWORD [ ATTR ] ] ] -Returns a list of SQL statements to alter this table so that it is identical -to the provided table, also a DBIx::DBSchema::Table object. +Returns a list of SQL statements to alter this table's constraints (foreign +keys) so that they are identical to the provided table, also a +DBIx::DBSchema::Table object. The data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password. @@ -691,8 +692,6 @@ specified database, will attempt to use generic SQL syntax. =cut -#gosh, false laziness w/DBSchema::sql_update_schema - sub sql_alter_constraints { my($self, $opt, $new, $dbh) = ( shift, _parse_opt(\@_), shift, _dbh(@_) ); @@ -713,8 +712,10 @@ sub sql_alter_constraints { push @at, 'ADD '. $foreign_key->sql_foreign_key; } - # XXX foreign keys modify / drop - + ### + # XXX TODO foreign keys modify / drop + ### + return () unless @at; ( 'ALTER TABLE '. $self->name. ' '. join(",\n ", @at) -- 2.11.0