class
CQL::ForeignKey
- CQL::ForeignKey
- Reference
- Object
Overview
A foreign key constraint: the local columns, the referenced table and columns,
and the ON DELETE / ON UPDATE actions. Declare one with Table#foreign_key
in a table block, or add one later with AlterTable#foreign_key.
Example Declaring a foreign key
schema.table :comments do
primary :id, Int64
column :post_id, Int64
foreign_key [:post_id], references: :posts, references_columns: [:id], on_delete: :cascade
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).