Module: SchemaPlusPgIndexes::Middleware::Postgresql::Dumper::Indexes
- Defined in:
- lib/schema_plus_pg_indexes/middleware/postgresql/dumper.rb
Instance Method Summary collapse
-
#after(env) ⇒ Object
Dump index extensions.
Instance Method Details
#after(env) ⇒ Object
Dump index extensions
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/schema_plus_pg_indexes/middleware/postgresql/dumper.rb', line 9 def after(env) index_defs = Dumper.get_index_definitions(env, env.table) env.table.indexes.each do |index_dump| index_def = index_defs.find(&its.name == index_dump.name) index_dump.add_option "case_sensitive: false" unless index_def.case_sensitive? index_dump.add_option "expression: #{index_def.expression.inspect}" if index_def.expression and index_def.case_sensitive? unless index_def.operator_classes.blank? if index_def.columns.uniq.length <= 1 && index_def.operator_classes.values.uniq.length == 1 index_dump.add_option "operator_class: #{index_def.operator_classes.values.first.inspect}" else index_dump.add_option "operator_class: {" + index_def.operator_classes.map{|column, val| "#{column.inspect}=>#{val.inspect}"}.join(", ") + "}" end end end end |