Skip to content

Commit

Permalink
Check for exisiting deduplication_key index before removing
Browse files Browse the repository at this point in the history
If you run the migration from the previous commit and there
are exisiting non-unique records, the migration will fail.

The exisiting index will be removed, but when you run
migrations again they will fail because the index can
no longer be removed.
  • Loading branch information
little9 committed Nov 5, 2019
1 parent 77b226c commit 05b0f05
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddUniquenessConstraintToPreIngestWorkDeduplicationKey < ActiveRecord::Migration[5.1]
def change
remove_index :zizia_pre_ingest_works, :deduplication_key if index_exists?(:zizia_pre_ingest_works, :deduplication_key)
add_index :zizia_pre_ingest_works, :deduplication_key, unique: true
end
end

0 comments on commit 05b0f05

Please sign in to comment.