class

Avram::Migrator::DropIndexStatement

Inherits Avram::Migrator::IndexStatementHelpers < Reference < Object

Builds an SQL statement for dropping an index by inferring it's name using table name and column(s).

Usage

For a single column index:

DropIndexStatement.new(:users, :email, if_exists: true, on_delete: :cascade).build
# => "DROP INDEX IF EXISTS users_email_index CASCADE;"

For multiple column index:

DropIndexStatement.new(:users, [:email, :username] if_exists: true, on_delete: :cascade).build
# => "DROP INDEX IF EXISTS users_email_username_index CASCADE;"

For index by name:

DropIndexStatement.new(:users, name: :custom_index_name).build
# => "DROP INDEX custom_index_name;"

Constants

ALLOWED_ON_DELETE_STRATEGIES = [:cascade, :restrict] of ::Symbol

Constructors

new(table : TableName, columns : Columns | Nil = nil, if_exists : Bool = false, on_delete : Symbol = :do_nothing, name : String | Nil | Symbol | Nil = nil)
Source

Instance methods

build
Source
on_delete_strategy(on_delete = :do_nothing)
Source