From: Rafael Kitover Date: Thu, 10 Jun 2010 05:44:33 +0000 (-0400) Subject: fix unique constraint names for SQLite (actual names break ->deploy) X-Git-Tag: 0.07001~28 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class-Schema-Loader.git;a=commitdiff_plain;h=4a1323d2bfc068aa8acec1ca3b85776fafba4783 fix unique constraint names for SQLite (actual names break ->deploy) --- diff --git a/Changes b/Changes index a2ae8a1..15b6311 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ Revision history for Perl extension DBIx::Class::Schema::Loader + - fix unique constraint names for SQLite (actual names break ->deploy) - fix bug in qualify_objects that would add schema to relnames - better type info for Informix, except for DATETIME precision and INTERVAL support diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm index 40ecec1..b181b9d 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm @@ -134,6 +134,7 @@ sub _table_uniq_info { my @uniqs; while (my $idx = $sth->fetchrow_hashref) { next unless $idx->{unique}; + my $name = $idx->{name}; my $get_idx_sth = $dbh->prepare("pragma index_info(" . $dbh->quote($name) . ")"); @@ -143,6 +144,11 @@ sub _table_uniq_info { push @cols, $self->_lc($idx_row->{name}); } $get_idx_sth->finish; + + # Rename because SQLite complains about sqlite_ prefixes on identifiers + # and ignores constraint names in DDL. + $name = (join '_', @cols) . '_unique'; + push @uniqs, [ $name => \@cols ]; } $sth->finish;