d024b9ab9e
Enforce uniqueness constraints at the database level, on: - Invites, - Procedures, - Individuals. These are the one less likely to have duplicates. A follow-up PR will contains similar migrations, but more likely to have existing duplicates that need to be removed.
14 lines
346 B
Ruby
14 lines
346 B
Ruby
class AddUniqueIndexToInvites < ActiveRecord::Migration[6.1]
|
|
include Database::MigrationHelpers
|
|
|
|
disable_ddl_transaction!
|
|
|
|
def up
|
|
delete_duplicates :invites, [:email, :dossier_id]
|
|
add_concurrent_index :invites, [:email, :dossier_id], unique: true
|
|
end
|
|
|
|
def down
|
|
remove_index :invites, column: [:email, :dossier_id]
|
|
end
|
|
end
|