class

Avram::Migrator::CreateForeignKeyStatement

Inherits Reference < Object

Generates an ALTER TABLE statement for adding a foreign key constraint on a table.

Usage

CreateForeignKeyStatement.new(from: :comments, to: :users, column: :author_id, primary_key: :uid, on_delete: :cascade).build
# => "ALTER TABLE comments ADD CONSTRAINT comments_author_id_fk FOREIGN KEY (author_id) REFERENCES users (uid) ON DELETE CASCADE;"

Constructors

new(from : TableName, to : TableName, on_delete : Symbol, column : Symbol | Nil = nil, primary_key : Symbol = :id)
Source

Instance methods

build
Source