class Avram::Migrator::DropIndexStatement

Overview

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;"

Included Modules

Defined in:

avram/migrator/drop_index_statement.cr

Constant Summary

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

Constructors

Instance Method 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 methods inherited from class Object

blank_for_validates_required? : Bool blank_for_validates_required?

Constructor Detail

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

[View source]

Instance Method Detail

def build #

[View source]
def on_delete_strategy(on_delete = :do_nothing) #

[View source]