Skip to content

Commit

Permalink
Merge pull request #27 from psarando/CORE-1955-app-ver-reorder
Browse files Browse the repository at this point in the history
CORE-1955 Add migration for deferrable app version order constraint
  • Loading branch information
psarando authored Oct 18, 2024
2 parents 74574ce + b3c6e85 commit 5549c93
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions migrations/000040_app_versions_deferred_constraints.down.sql
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 migrations/000040_app_versions_deferred_constraints.up.sql
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;

0 comments on commit 5549c93

Please sign in to comment.