be4c575622
The active scopes is used indirectly in the dossier<->gestionnaire associations: the existing tests in dossier and gestionnaire just work™.
17 lines
722 B
Ruby
17 lines
722 B
Ruby
class AddFollowUnfollowedAt < ActiveRecord::Migration[5.2]
|
||
# We need up/down migrations because `remove_index` doesn’t allow `unique: true` and can’t be properly rolled back.
|
||
def up
|
||
add_column :follows, :unfollowed_at, :datetime
|
||
|
||
remove_index :follows, [:gestionnaire_id, :dossier_id]
|
||
add_index :follows, [:gestionnaire_id, :dossier_id, :unfollowed_at], unique: true,
|
||
name: :uniqueness_index # We need a custom name because the autogenerated name would be too long
|
||
end
|
||
|
||
def down
|
||
remove_column :follows, :unfollowed_at
|
||
# We don’t need to remove the index: dropping the column automatically deletes it.
|
||
|
||
add_index :follows, [:gestionnaire_id, :dossier_id], unique: true
|
||
end
|
||
end
|