From 2f507dfb85dcb9be5400d8bf3654566e2853e402 Mon Sep 17 00:00:00 2001 From: PRATIK MISHRA <43684300+pratikmishra356@users.noreply.github.com> Date: Fri, 3 Jan 2025 13:17:23 +0530 Subject: [PATCH] fix: add unique position contraint as deferred (#330) --- .../2024-12-05-172909_dimension_priority_default/down.sql | 4 +++- .../2024-12-05-172909_dimension_priority_default/up.sql | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/down.sql b/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/down.sql index 3e6713cb..178428c3 100644 --- a/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/down.sql +++ b/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/down.sql @@ -1,3 +1,5 @@ -- This file should undo anything in `up.sql` ALTER TABLE public.dimensions -ALTER COLUMN priority DROP DEFAULT; \ No newline at end of file +ALTER COLUMN priority DROP DEFAULT; + +ALTER table public.dimensions drop constraint if exists dimension_unique_position; \ No newline at end of file diff --git a/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/up.sql b/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/up.sql index 433b23e4..68631795 100644 --- a/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/up.sql +++ b/crates/context_aware_config/migrations/2024-12-05-172909_dimension_priority_default/up.sql @@ -3,4 +3,6 @@ ALTER TABLE public.dimensions ALTER COLUMN priority SET DEFAULT 1; ALTER TABLE public.dimensions -ADD CONSTRAINT dimension_unique_position UNIQUE (position); \ No newline at end of file +ADD CONSTRAINT dimension_unique_position UNIQUE (position) DEFERRABLE INITIALLY IMMEDIATE; + +SET CONSTRAINTS dimension_unique_position DEFERRED; \ No newline at end of file