Module: SchemaPlusPgIndexes::Middleware::Postgresql::Migration::Index

Defined in:
lib/schema_plus_pg_indexes/middleware/postgresql/migration.rb

Instance Method Summary collapse

Instance Method Details

#before(env) ⇒ Object

Deprecate args



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/schema_plus_pg_indexes/middleware/postgresql/migration.rb', line 8

def before(env)
  {:conditions => :where, :kind => :using}.each do |deprecated, proper|
    if env.options[deprecated]
      ActiveSupport::Deprecation.warn "ActiveRecord index option #{deprecated.inspect} is deprecated, use #{proper.inspect} instead"
      env.options[proper] = env.options.delete(deprecated)
    end
  end

  case env.caller.class.name
  when /TableDefinition/
    # When index creation is in table definition, create a dummy value for column_names,
    # since index definitions are indexed by column names
    env.column_names = dummy_column_names(env) if env.column_names.blank?
  else
    # For actual index creation, strip out the dummy column name
    # value
    env.column_names = [] if env.column_names == dummy_column_names(env)
  end
end

#dummy_column_names(env) ⇒ Object



28
29
30
# File 'lib/schema_plus_pg_indexes/middleware/postgresql/migration.rb', line 28

def dummy_column_names(env)
  ["--expression--", env.options[:expression]]
end