NAME
DBIO::PostgreSQL::Introspect::ForeignKeys - Introspect PostgreSQL foreign keys
VERSION
version 0.900007
DESCRIPTION
Fetches PostgreSQL foreign key metadata from pg_catalog.pg_constraint, including ordered local and remote columns plus referential actions and deferrability. Tables an installed extension owns are left out by DBIO::PostgreSQL::Introspect::Tables, and the foreign keys on them with them. A foreign key of a partitioned table, or onto one, is carried down by the server as copies with pg_constraint.conparentid set (one at each partition, one per partition a key onto a partitioned table points at); the copies go with the declared key and are left out of the model. A foreign key from one of the schema's own tables to such a table is the schema's and is reported.
METHODS
fetch
my $foreign_keys = DBIO::PostgreSQL::Introspect::ForeignKeys->fetch($dbh, $filter);
Returns a hashref keyed by schema.table. Each value is an ArrayRef of foreign key hashrefs with keys: constraint_name, remote_schema, remote_table, local_columns, remote_columns, on_delete, on_update, deferrable and initially_deferred (pg_constraint.condeferrable, condeferred), is_deferrable (the same value as deferrable, kept for readers of the older key), and three that say what else the server holds of the key:
is_valid-
pg_constraint.convalidated: 1, or 0 for a key addedNOT VALIDand not yet validated. match-
pg_constraint.confmatchtypeas the word:SIMPLE(the default),FULL. on_delete_columns-
The columns named by
ON DELETE SET NULL (columns)orON DELETE SET DEFAULT (columns), in the order written (PostgreSQL 15 and later;pg_constraint.confdelsetcols). An empty ArrayRef for a key that names none, and on a server that has no such column.
AUTHOR
DBIO & DBIx::Class Authors
COPYRIGHT AND LICENSE
Copyright (C) 2026 DBIO Authors Portions Copyright (C) 2005-2025 DBIx::Class Authors Based on DBIx::Class, heavily modified.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.