Sha256: b799169f231529cf90b4825c804d4db2b1d48636acfb56ef47f30fed8024b7b1
Contents?: true
Size: 858 Bytes
Versions: 6
Compression:
Stored size: 858 Bytes
Contents
class AddConstraintsToMostRecentFor<%= migration_class_name %> < ActiveRecord::Migration disable_ddl_transaction! def up <%- if database_supports_partial_indexes? -%> add_index :<%= table_name %>, [:<%= parent_id %>, :most_recent], unique: true, where: "most_recent", name: "index_<%= table_name %>_parent_most_recent", algorithm: :concurrently change_column_null :<%= table_name %>, :most_recent, false <%- else -%> add_index :<%= table_name %>, [:<%= parent_id %>, :most_recent], unique: true, name: "index_<%= table_name %>_parent_most_recent", algorithm: :concurrently <%- end -%> end def down remove_index :<%= table_name %>, name: "index_<%= table_name %>_parent_most_recent" <%- if database_supports_partial_indexes? -%> change_column_null :<%= table_name %>, :most_recent, true <%- end -%> end end
Version data entries
6 entries across 6 versions & 2 rubygems