Add Follow.unfollowed_at
The active scopes is used indirectly in the dossier<->gestionnaire associations: the existing tests in dossier and gestionnaire just work™.
This commit is contained in:
parent
d417907f36
commit
be4c575622
5 changed files with 29 additions and 6 deletions
17
db/migrate/20190607124156_add_follow_unfollowed_at.rb
Normal file
17
db/migrate/20190607124156_add_follow_unfollowed_at.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue