DBSchema::ForeignKey(3pm) User Contributed Perl Documentation DBSchema::ForeignKey(3pm)

DBIx::DBSchema::ForeignKey - Foreign key objects

  use DBIx::DBSchema::ForeignKey;
  $foreign_key = new DBIx::DBSchema::ForeignKey (
    { 'columns' => [ 'column_name' ],
      'table'   => 'foreign_table',
    }
  );
  $foreign_key = new DBIx::DBSchema::ForeignKey (
    {
      'constraint' => 'constraint_name',
      'columns'    => [ 'column_name', 'column2' ],
      'table'      => 'foreign_table',
      'references' => [ 'foreign_column', 'foreign_column2' ],
      'match'      => 'MATCH FULL', # or MATCH SIMPLE
      'on_delete'  => 'NO ACTION', # on clauses: NO ACTION / RESTRICT /
      'on_update'  => 'RESTRICT',  #           CASCADE / SET NULL / SET DEFAULT
    }
  );

DBIx::DBSchema::ForeignKey objects represent a foreign key.

Creates a new DBIx::DBschema::ForeignKey object.

Accepts either a hashref or a list of options and values.

Options are:

Returns or sets the constraint name
Returns or sets the foreign table name
Returns or sets the columns.
Returns a comma-joined list of columns, suitable for an SQL statement.
Returns or sets the referenced columns.
Returns a comma-joined list of referenced columns, suitable for an SQL statement.
Returns or sets the MATCH clause
Returns or sets the ON DELETE clause
Returns or sets the ON UPDATE clause
Returns an SQL FOREIGN KEY statement.
Compares this object to another supplied object. Returns true if they are have the same table, columns and references.

Ivan Kohler <ivan-dbix-dbschema@420.am>

Copyright (c) 2013 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Should give in and Mo or Moo.

DBIx::DBSchema::Table, DBIx::DBSchema, DBI

2022-09-10 perl v5.36.0