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.build do
table :users do
 column :id, Int32, primary: true
column :name, String
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

Instance Method Summary

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]

Instance Method Detail

def columns : Array(Symbol) #

[View source]
def name : Symbol #

[View source]
def on_delete : String #

[View source]
def on_update : String #

[View source]
def references : Array(Symbol) #

[View source]
def table : Symbol #

[View source]