From: Jess Robinson Date: Mon, 20 Nov 2006 23:56:14 +0000 (+0000) Subject: Cascade drop pg tables to overcome key constraints when dropping X-Git-Tag: v0.11008~390 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cc00c034bcfb007c0e4db411949a3af5c0ff6900;p=dbsrgits%2FSQL-Translator.git Cascade drop pg tables to overcome key constraints when dropping --- diff --git a/lib/SQL/Translator/Producer/PostgreSQL.pm b/lib/SQL/Translator/Producer/PostgreSQL.pm index eb12613..10976e8 100644 --- a/lib/SQL/Translator/Producer/PostgreSQL.pm +++ b/lib/SQL/Translator/Producer/PostgreSQL.pm @@ -1,7 +1,7 @@ package SQL::Translator::Producer::PostgreSQL; # ------------------------------------------------------------------- -# $Id: PostgreSQL.pm,v 1.27 2006-11-10 21:21:51 mwz444 Exp $ +# $Id: PostgreSQL.pm,v 1.28 2006-11-20 23:56:14 schiffbruechige Exp $ # ------------------------------------------------------------------- # Copyright (C) 2002-4 SQLFairy Authors # @@ -39,7 +39,7 @@ producer. use strict; use warnings; use vars qw[ $DEBUG $WARN $VERSION ]; -$VERSION = sprintf "%d.%02d", q$Revision: 1.27 $ =~ /(\d+)\.(\d+)/; +$VERSION = sprintf "%d.%02d", q$Revision: 1.28 $ =~ /(\d+)\.(\d+)/; $DEBUG = 1 unless defined $DEBUG; use SQL::Translator::Schema::Constants; @@ -377,7 +377,7 @@ sub create_table my $create_statement; $create_statement = join("\n", @comments); - $create_statement .= qq[DROP TABLE $qt$table_name_ur$qt;\n] + $create_statement .= qq[DROP TABLE $qt$table_name_ur$qt CASCADE;\n] if $add_drop_table; $create_statement .= qq[CREATE TABLE $qt$table_name_ur$qt (\n]. join( ",\n", map { " $_" } @field_defs, @constraint_defs ). diff --git a/t/46xml-to-pg.t b/t/46xml-to-pg.t index de42837..0fd269c 100644 --- a/t/46xml-to-pg.t +++ b/t/46xml-to-pg.t @@ -33,7 +33,7 @@ my $sql = $sqlt->translate( ) or die $sqlt->error; is($sql, << "SQL"); -DROP TABLE "Basic"; +DROP TABLE "Basic" CASCADE; CREATE TABLE "Basic" ( "id" serial NOT NULL, "title" character varying(100) DEFAULT 'hello' NOT NULL, @@ -51,7 +51,7 @@ CREATE TABLE "Basic" ( CREATE INDEX "titleindex" on "Basic" ("title"); -DROP TABLE "Another"; +DROP TABLE "Another" CASCADE; CREATE TABLE "Another" ( "id" serial NOT NULL, PRIMARY KEY ("id") diff --git a/t/49xml-to-pg-samefield.t b/t/49xml-to-pg-samefield.t index 4fb029d..4ec2644 100644 --- a/t/49xml-to-pg-samefield.t +++ b/t/49xml-to-pg-samefield.t @@ -33,14 +33,14 @@ my $sql = $sqlt->translate( ) or die $sqlt->error; is($sql, << "SQL"); -DROP TABLE "one"; +DROP TABLE "one" CASCADE; CREATE TABLE "one" ( "same" character varying(100) DEFAULT 'hello' NOT NULL ); -DROP TABLE "two"; +DROP TABLE "two" CASCADE; CREATE TABLE "two" ( "same" character varying(100) DEFAULT 'hello' NOT NULL );