class BazaMigrations::Commands::RemoveIndex
Public Class Methods
new(table_name, column_name)
click to toggle source
# File lib/baza_migrations/commands/remove_index.rb, line 2 def initialize(table_name, column_name) @table_name = table_name if column_name.is_a?(Array) @index_name = "index_#{@table_name}_on_#{column_name.join("_and_")}" else @index_name = "index_#{@table_name}_on_#{column_name}" end end
Public Instance Methods
changed_rollback_sql()
click to toggle source
# File lib/baza_migrations/commands/remove_index.rb, line 30 def changed_rollback_sql raise BazaMigrations::Errors::IrreversibleMigration end
sql()
click to toggle source
# File lib/baza_migrations/commands/remove_index.rb, line 12 def sql sqls = [] db_type = db.opts.fetch(:type) if db_type.to_s.include?("sqlite3") sqls << proc do table = db.tables[@table_name] index = table.index(@index_name) index.drop end else sqls << "DROP INDEX `#{@index_name}` ON `#{@table_name}`" end sqls end