Skip to content

Commit

Permalink
Remove uniqueness constraint from deduplication_key
Browse files Browse the repository at this point in the history
Adding a unique constraint to the `deduplication_key` solved
grouping for an initial import, but it causes problems when
you re-import. After a re-import `PreIngestFile`s are added to
the existing `PreIngestWork`s which are assoicated with existing
`CsvImportDetail`s.
  • Loading branch information
little9 committed Nov 5, 2019
1 parent bbc4fe8 commit 4c044c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class RemoveUniquenessConstraintToPreIngestWorkDeduplicationKey < 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: false
end
end
2 changes: 1 addition & 1 deletion spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
t.datetime "updated_at", null: false
t.string "deduplication_key"
t.index ["csv_import_detail_id"], name: "index_zizia_pre_ingest_works_on_csv_import_detail_id"
t.index ["deduplication_key"], name: "index_zizia_pre_ingest_works_on_deduplication_key", unique: true
t.index ["deduplication_key"], name: "index_zizia_pre_ingest_works_on_deduplication_key"
end

end

0 comments on commit 4c044c0

Please sign in to comment.