module Avram::Migrator::StatementHelpers

Included Modules

Direct including types

Defined in:

avram/migrator/statement_helpers.cr

Instance Method Summary

Macro Summary

Instance methods inherited from module Avram::Migrator::IndexStatementHelpers

add_index(column : Symbol, unique = false, using : Symbol = :btree) add_index, index_added?(index : String, column : Symbol) index_added?

Instance Method Detail

def create_foreign_key(from : TableName, to : TableName, on_delete : Symbol, column : Symbol | Nil, primary_key = :id) #

[View source]
def create_function(name : String, body : String, returns : String = "trigger") #

[View source]
def create_index(table_name : TableName, columns : Columns, unique = false, using = :btree, name : String | Nil | Symbol | Nil = nil) #

[View source]
def 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();

[View source]
def disable_extension(name : String) #

[View source]
def drop(table_name) #

[View source]
def drop_foreign_key(from : TableName, references : TableName, column : Symbol | Nil) #

[View source]
def drop_function(name : String) #

[View source]
def drop_index(table_name : TableName, columns : Columns | Nil = nil, if_exists = false, on_delete = :do_nothing, name : String | Nil | Symbol | Nil = nil) #

[View source]
def drop_trigger(table_name : TableName, name : String) #

Drop the tigger name for the table table_name


[View source]
def enable_extension(name : String) #

[View source]
def make_optional(table : TableName, column : Symbol) #

[View source]
def make_required(table : TableName, column : Symbol) #

[View source]
def update_extension(name : String, to : String | Nil = nil) #

[View source]

Macro Detail

macro alter(table_name) #

[View source]
macro create(table_name) #

[View source]