-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove duplicates prior to adding unique index on contract API ID
Also ensure ID is always unset when creating a new API. Signed-off-by: Andrew Richardson <andrew.richardson@kaleido.io>
- Loading branch information
Showing
3 changed files
with
6 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
db/migrations/postgres/000108_create_contractapis_id_index.up.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,3 +1,5 @@ | ||
BEGIN; | ||
DELETE FROM contractapis WHERE seq NOT IN ( | ||
SELECT MAX(seq) FROM contractapis GROUP BY namespace, id); | ||
CREATE UNIQUE INDEX contractapis_id ON contractapis(namespace,id); | ||
COMMIT; |
2 changes: 2 additions & 0 deletions
2
db/migrations/sqlite/000108_create_contractapis_id_index.up.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,3 @@ | ||
DELETE FROM contractapis WHERE seq NOT IN ( | ||
SELECT MAX(seq) FROM contractapis GROUP BY namespace, id); | ||
CREATE UNIQUE INDEX contractapis_id ON contractapis(namespace,id); |
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