Module: SchemaPlus::Indexes::Middleware::Migration::Column

Defined in:
lib/schema_plus/indexes/middleware/migration.rb

Instance Method Summary collapse

Instance Method Details

#after(env) ⇒ Object

Support :index option in Migration.add_column



16
17
18
19
20
21
22
# File 'lib/schema_plus/indexes/middleware/migration.rb', line 16

def after(env)
  return unless env.options[:index]
  case env.operation
  when :add, :record
    env.caller.add_index(env.table_name, env.column_name, env.options[:index])
  end
end

#before(env) ⇒ Object

Shortcuts



8
9
10
11
12
13
# File 'lib/schema_plus/indexes/middleware/migration.rb', line 8

def before(env)
  case env.options[:index]
  when true then env.options[:index] = {}
  when :unique then env.options[:index] = { :unique => true }
  end
end