module

Avram::Migrator::StatementHelpers

Inherits Avram::TableFor < Avram::Migrator::IndexStatementHelpers

Instance methods

create_foreign_key(from : TableName, to : TableName, on_delete : Symbol, column : Symbol | Nil, primary_key = :id)
Source
create_function(name : String, body : String, returns : String = "trigger", language : String = "plpgsql", behavior : Avram::Migrator::CreateFunctionStatement::Behavior = Avram::Migrator::CreateFunctionStatement::Behavior::VOLATILE)
Source
create_index(table_name : TableName, columns : Columns, unique = false, concurrently = false, using = :btree, name : String | Nil | Symbol | Nil = nil)
Source
create_sequence(table : TableName, column : Symbol)
Source
create_trigger(table_name : TableName, name : String, function_name : String, callback : Symbol = :before, on : Array(Symbol) = [:update])

Drop any existing trigger by this name first before creating. Postgres does not support updating or replacing a trigger as of version 12

Creates a new TRIGGER named name on the table table_name. function_name - The PG function to run from this trigger. callback - When to run this trigger (BEFORE or AFTER). Default :before on - The operation(s) for this trigger (INSERT, UPDATE, DELETE). Default is [:update]

create_trigger(:users, "trigger_set_timestamps", "set_timestamps")
# => CREATE TRIGGER trigger_set_timestamps BEFORE UPDATE ON users FOR EACH ROW EXECUTE PROCEDURE set_timestamps();
Source
disable_extension(name : String)
Source
drop(table_name, *, if_exists = false)
Source
drop_foreign_key(from : TableName, references : TableName, column : Symbol | Nil)
Source
drop_function(name : String)
Source
drop_index(table_name : TableName, columns : Columns | Nil = nil, if_exists = false, on_delete = :do_nothing, name : String | Nil | Symbol | Nil = nil)
Source
drop_sequence(table : TableName, column : Symbol)
Source
drop_trigger(table_name : TableName, name : String)

Drop the tigger name for the table table_name

Source
enable_extension(name : String)
Source
make_optional(table : TableName, column : Symbol)
Source
make_required(table : TableName, column : Symbol)
Source
update_extension(name : String, to : String | Nil = nil)
Source

Macros

alter(table_name, *, if_exists = false)
Source
create(table_name, *, if_not_exists = false)
Source