class Avram::Migrator::AlterTableStatement
Included Modules
Defined in:
avram/migrator/alter_table_statement.crConstructors
Instance Method Summary
- #add_change_type_statement(column : Avram::Migrator::Columns::Base)
- #add_fill_existing_with_statements(column : Symbol | String, type, value)
- #alter_statements : Array(String)
-
#build(&)
Accepts a block to alter a table using the
add
method. - #change_type_statements : Array(String)
- #dropped_rows : Array(String)
- #fill_existing_with_statements : Array(String)
- #remove(name : Symbol)
- #rows : Array(String)
- #statements
Macro Summary
- add(type_declaration, index = false, using = :btree, unique = false, default = nil, fill_existing_with = nil, **type_options)
-
add_belongs_to(type_declaration, on_delete, references = nil, foreign_key_type = Int64)
Adds a references column and index given a model class and references option.
- change_type(type_declaration, **type_options)
- remove_belongs_to(association_name)
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 methods inherited from class Object
blank_for_validates_required? : Bool
blank_for_validates_required?
Constructor Detail
Instance Method Detail
def build(&)
#
Accepts a block to alter a table using the add
method. The generated sql
statements are aggregated in the #statements
getter.
Usage
built = Avram::Migrator::AlterTableStatement.new(:users).build do
add name : String
add age : Int32
remove old_field
end
built.statements
# => [
"ALTER TABLE users
ADD name text NOT NULL,
ADD age int NOT NULL,
DROP old_field"
]
Macro Detail
macro add(type_declaration, index = false, using = :btree, unique = false, default = nil, fill_existing_with = nil, **type_options)
#
Adds a references column and index given a model class and references option.