NAME

DBIO::MySQL::Introspect::ForeignKeys - Introspect MySQL/MariaDB foreign keys

VERSION

version 0.900000

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.

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.