module SchemaPlus::Indexes::Middleware::Dumper::Table
Public Instance Methods
after(env)
click to toggle source
# File lib/schema_plus/indexes/middleware/dumper.rb, line 8 def after(env) # move each column's index to its column, and remove them from the # list of indexes that AR would dump after the table. Any left # over will still be dumped by AR. env.table.columns.each do |column| # first check for a single-column index if (index = env.table.indexes.find{ |it| it.columns == [column.name] }) column.options[:index] = index_options(env, column, index) env.table.indexes.delete(index) # then check for the first of a multi-column index elsif (index = env.table.indexes.find { |it| it.columns.first == column.name }) column.options[:index] = index_options(env, column, index) env.table.indexes.delete(index) end end end
index_options(env, column, index)
click to toggle source
# File lib/schema_plus/indexes/middleware/dumper.rb, line 30 def index_options(env, column, index) options = {} options[:name] = index.name options[:with] = (index.columns - [column.name]) if index.columns.length > 1 options.merge index.options end