Subject: | PATCH: PostgreSQL adding foreign key doesn't name the constraint |
The producer for PostgreSQL does not name foreign keys, even though it
is already generated. Attached is a patch that adds $def_start to the
alter statement.
Subject: | patch0.patch |
--- a/lib/perl5/SQL/Translator/Producer/PostgreSQL.pm
+++ b/lib/perl5/SQL/Translator/Producer/PostgreSQL.pm
@@ -675,7 +675,7 @@ sub create_constraint
push @constraint_defs, "${def_start}CHECK ($expression)";
}
elsif ( $c->type eq FOREIGN_KEY ) {
- my $def .= "ALTER TABLE ${qt}${table_name}${qt} ADD FOREIGN KEY (" .
+ my $def .= "ALTER TABLE ${qt}${table_name}${qt} ADD ${def_start}FOREIGN KEY (" .
join( ', ', map { qq[$qf$_$qf] } @fields ) . ')' .
"\n REFERENCES " . $qt . $c->reference_table . $qt;