1 package DBIx::Class::Schema::Loader::DBI::Pg;
5 use base 'DBIx::Class::Schema::Loader::DBI';
10 DBIx::Class::Schema::Loader::DBI::Pg - DBIx::Class::Schema::Loader::DBI Postgres Implementation.
15 use base qw/DBIx::Class::Schema::Loader/;
17 __PACKAGE__->loader_options(
25 See L<DBIx::Class::Schema::Loader::Base>.
32 $self->next::method(@_);
33 $self->{db_schema} ||= 'public';
36 sub _table_uniq_info {
37 my ($self, $table) = @_;
40 my $dbh = $self->schema->storage->dbh;
42 my $sth = $dbh->prepare_cached(
43 qq{SELECT conname,indexdef FROM pg_indexes JOIN pg_constraint }
44 . qq{ON (pg_indexes.indexname = pg_constraint.conname) }
45 . qq{WHERE schemaname=? and tablename=? and contype = 'u'}
48 $sth->execute($self->db_schema, $table);
49 while(my $constr = $sth->fetchrow_arrayref) {
50 my $constr_name = $constr->[0];
51 my $constr_def = $constr->[1];
53 if($constr_def =~ /\(\s*([^)]+)\)\s*$/) {
55 $cols_text =~ s/\s+$//;
56 @cols = map { lc } split(/\s*,\s*/, $cols_text);
57 s/\Q$self->{_quoter}\E// for @cols;
60 warn "Failed to parse unique constraint $constr_name on $table";
63 push(@uniqs, [ $constr_name => \@cols ]);
72 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
73 L<DBIx::Class::Schema::Loader::DBI>