-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition in
doesProjectExist
... by enforcing uniqueness as database constraints, instead of trying to do it in the application code. This bug affects DT v4.x as well, but because we can't create partial indexes there (DataNucleus doesn't give us that much control), we can't really fix it. Fixes DependencyTrack/hyades#1101 Signed-off-by: nscuro <[email protected]>
- Loading branch information
Showing
4 changed files
with
71 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog | ||
objectQuotingStrategy="QUOTE_ALL_OBJECTS" | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd | ||
http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet id="v5.4.0-1" author="[email protected]"> | ||
<!-- | ||
Create two partial unique indexes to cover cases where VERSION is NULL. | ||
Per default, NULLs are considered to be unique values. | ||
PostgreSQL 15 supports NULLS NOT DISTINCT: https://stackoverflow.com/a/8289253 | ||
But we are far away from being able to raise the baseline version to 15. | ||
--> | ||
<sql splitStatements="true"> | ||
CREATE UNIQUE INDEX "PROJECT_NAME_VERSION_IDX" ON "PROJECT" ("NAME", "VERSION") | ||
WHERE "VERSION" IS NOT NULL; | ||
CREATE UNIQUE INDEX "PROJECT_NAME_VERSION_NULL_IDX" ON "PROJECT" ("NAME") | ||
WHERE "VERSION" IS NULL; | ||
</sql> | ||
</changeSet> | ||
</databaseChangeLog> |