Subject: | cross-schema foreign keys not supported (Pg) |
Foreign keys across database schemas break the loading of relationships.
Example in Pg:
SQL:
====
CREATE SCHEMA foo;
CREATE SCHEMA bar;
CREATE TABLE foo.main (id integer PRIMARY KEY);
CREATE TABLE bar.baz (fk_foo integer REFERENCES foo.main(id));
Perl:
=====
DBIx::Class::Schema::Loader->load_from_connection(
connect_info => ['dbi:Pg:dbname=demo' ... ],
relationships => 1,
debug => 1,
db_schema => 'bar'
);
Result:
=======
### START DBIx::Class::Schema::Loader dump ###
# Initializing table "baz" as "DBIx::Class::Schema::Loader::Baz"
baz has no primary key at
/usr/lib/perl5/vendor_perl/5.8.6/DBIx/Class/Schema/Loader.pm line 145
DBIx::Class::Schema::Loader::Baz->table('baz');
DBIx::Class::Schema::Loader::Baz->add_columns('fk_foo')
Can't use an undefined value as an ARRAY reference at
/usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/DBD/Pg.pm line 800.
DBD::Pg is version 1.49.
The culprit is line 461 in DBIx/Class/Schema/Loader/Generic.pm, in
function _load_relationships. The call to foreign_key_info specifies the
db_schema for PKTABLE_SCHEM, only looking within db_schema.