mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-08 12:10:19 +08:00
fix(data): make postgres snapshot migrations idempotent
This commit is contained in:
+4
@@ -30,5 +30,9 @@ BEGIN
|
||||
ADD CONSTRAINT ldap_configs_singleton_key_key UNIQUE (singleton_key);
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN NULL;
|
||||
-- The empty-database snapshot already materializes this constraint. PostgreSQL
|
||||
-- reports the existing constraint's backing relation as duplicate_table (42P07)
|
||||
-- rather than duplicate_object, so treat that known idempotent case the same way.
|
||||
WHEN duplicate_table THEN NULL;
|
||||
END
|
||||
$migration$;
|
||||
|
||||
+4
-1
@@ -1,5 +1,8 @@
|
||||
ALTER TABLE public.routing_groups
|
||||
ADD COLUMN sort_order bigint NOT NULL DEFAULT 0;
|
||||
-- The empty-database snapshot may already contain the current logical
|
||||
-- schema. Keep the incremental migration safe for both snapshot and
|
||||
-- legacy databases.
|
||||
ADD COLUMN IF NOT EXISTS sort_order bigint NOT NULL DEFAULT 0;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS routing_groups_enabled_sort_idx
|
||||
ON public.routing_groups (enabled DESC, sort_order, name, id);
|
||||
|
||||
Reference in New Issue
Block a user