class Cql::ForeignKey

Overview

A foreign key constraint This class represents a foreign key constraint It provides methods for setting the columns, table, and references It also provides methods for setting the on delete and on update actions

Example Creating a new foreign key

Schema.define do
  table :users do
    column :id, Int32, primary: true
    column :name, String
  end
end

table :posts do
  column :id, Int32, primary: true
  column :user_id, Int32
  foreign_key [:user_id], :users, [:id]
end

Defined in:

foreign_key.cr

Constructors

Constructor Detail

def self.new(name : Symbol, columns : Array(Symbol), table : Symbol, references : Array(Symbol), on_delete : String = "NO ACTION", on_update : String = "NO ACTION") #

[View source]