Skip to content

Commit

Permalink
Another unrelated experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
tagliala committed Nov 24, 2021
1 parent bc7bddb commit eabd122
Showing 1 changed file with 4 additions and 17 deletions.
21 changes: 4 additions & 17 deletions lib/chrono_model/adapter/migrations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,31 +105,18 @@ def drop_table(table_name, *)
# temporal schema and to the history one. If the `:unique` option is
# present, it is removed from the index created in the history table.
#
def add_index(table_name, column_name, options = {})
def add_index(table_name, column_name, **options)
unless is_chrono?(table_name)
return super if RUBY_VERSION < '3.0.0'
return super(table_name, column_name, **options)
return super
end

transaction do
on_temporal_schema do
if RUBY_VERSION < '3.0.0'
super
else
super(table_name, column_name, **options)
end
end
on_temporal_schema { super }

# Uniqueness constraints do not make sense in the history table
options = options.dup.tap {|o| o.delete(:unique)} if options[:unique].present?

on_history_schema do
if RUBY_VERSION < '3.0.0'
super table_name, column_name, options
else
super table_name, column_name, **options
end
end
on_history_schema { super }
end
end

Expand Down

0 comments on commit eabd122

Please sign in to comment.