-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switched to a conditional constraint. (#7451)
- Loading branch information
Showing
1 changed file
with
10 additions
and
1 deletion.
There are no files selected for viewing
11 changes: 10 additions & 1 deletion
11
src/main/resources/db/migration/V5.4.0.1__7451-unique-constraint-storageidentifier.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
ALTER TABLE dvobject ADD CONSTRAINT unq_dvobject_storageidentifier UNIQUE(owner_id, storageidentifier); | ||
-- ALTER TABLE dvobject ADD CONSTRAINT unq_dvobject_storageidentifier UNIQUE(owner_id, storageidentifier); | ||
-- Instead of a uniform constraint on all dvobjects (as above), force a | ||
-- conditional unique constraint on datafiles only: | ||
CREATE UNIQUE INDEX IF NOT EXISTS unq_dvobject_storageidentifier ON dvobject (owner_id, storageidentifier) WHERE dtype='DataFile'; | ||
-- This is not going to have any effect on new databases (since v4.20+), | ||
-- where the table was created with the full constraint; but for legacy | ||
-- installations it would spare them having to clean up any dataset-level | ||
-- storageidentifiers. We know that some old installations have datasets | ||
-- with junk values in that column (like "file" - ??) that are meaningless, | ||
-- but otherwise harmless. |