-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from psarando/CORE-1955-app-ver-reorder
CORE-1955 Add migration for deferrable app version order constraint
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
migrations/000040_app_versions_deferred_constraints.down.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
BEGIN; | ||
|
||
SET search_path = public, pg_catalog; | ||
|
||
ALTER TABLE ONLY app_versions | ||
DROP CONSTRAINT IF EXISTS app_versions_app_id_version_order_key; | ||
|
||
ALTER TABLE ONLY app_versions | ||
ADD CONSTRAINT app_versions_app_id_version_order_key | ||
UNIQUE (app_id, version_order); | ||
|
||
COMMIT; |
14 changes: 14 additions & 0 deletions
14
migrations/000040_app_versions_deferred_constraints.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
BEGIN; | ||
|
||
SET search_path = public, pg_catalog; | ||
|
||
ALTER TABLE ONLY app_versions | ||
DROP CONSTRAINT IF EXISTS app_versions_app_id_version_order_key; | ||
|
||
-- Make the version_order unique constraint deferrable | ||
-- so that the order can be updated in a transaction. | ||
ALTER TABLE ONLY app_versions | ||
ADD CONSTRAINT app_versions_app_id_version_order_key | ||
UNIQUE (app_id, version_order) DEFERRABLE INITIALLY DEFERRED; | ||
|
||
COMMIT; |