class
CQL::ForeignKey
- CQL::ForeignKey
- Reference
- Object
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.crConstructors
Instance Method Summary
-
#columns : Array(Symbol)
The column(s) in the current table that make up the foreign key.
-
#name : String | Nil
Name of the foreign key constraint (optional, often auto-generated).
-
#on_delete : Symbol
Action to perform on delete (e.g., :cascade, :restrict, :set_null, :no_action).
-
#on_update : Symbol
Action to perform on update (e.g., :cascade, :restrict, :set_null, :no_action).
-
#references_columns : Array(Symbol)
The column(s) in the referenced table.
-
#references_table : Symbol
The table that the foreign key references.
-
#table : CQL::Table
The table this foreign key constraint belongs to.
Constructor Detail
Instance Method Detail
Action to perform on delete (e.g., :cascade, :restrict, :set_null, :no_action).
Action to perform on update (e.g., :cascade, :restrict, :set_null, :no_action).