NAME
DBIO::MySQL::Introspect::ForeignKeys - Introspect MySQL/MariaDB foreign keys
VERSION
version 0.900004
DESCRIPTION
Fetches foreign key metadata by joining information_schema.key_column_usage against information_schema.referential_constraints, scoped to the current DATABASE() and filtered to the tables surfaced by DBIO::MySQL::Introspect::Tables. Composite foreign keys are grouped per constraint via "_aggregate_by_ordered" in DBIO::Introspect::Base (preserves both first-seen table/constraint order and the column pairing within each constraint).
METHODS
fetch
my $fks = DBIO::MySQL::Introspect::ForeignKeys->fetch($dbh, $tables);
Given the tables hashref from DBIO::MySQL::Introspect::Tables, returns a hashref keyed by table name. Each value is an arrayref of foreign key hashrefs (one per constraint) with keys: constraint_name, from_columns (arrayref), to_table, to_columns (arrayref), on_update, on_delete.
on_update and on_delete are what information_schema reports, with one exception: on a MariaDB, NO ACTION is read as RESTRICT. MariaDB stores RESTRICT where the DDL names no action (what install_ddl writes for NO ACTION), but keeps an explicit NO ACTION of a constraint made by hand or by another tool; both check at once, and a diff that compared the two words would drop and add the same constraint. MySQL reports NO ACTION and RESTRICT and they stay two. Which server it is, the version string says (SELECT VERSION()), as in DBIO::MySQL::Introspect::Columns.
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.