diff --git a/crates/aether-data/adapters/postgres/migrations/20260831000000_enforce_ldap_config_singleton.sql b/crates/aether-data/adapters/postgres/migrations/20260831000000_enforce_ldap_config_singleton.sql index 29ee24248..9a34a8d7b 100644 --- a/crates/aether-data/adapters/postgres/migrations/20260831000000_enforce_ldap_config_singleton.sql +++ b/crates/aether-data/adapters/postgres/migrations/20260831000000_enforce_ldap_config_singleton.sql @@ -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$; diff --git a/crates/aether-data/adapters/postgres/migrations/20260903000000_add_routing_group_sort_order.sql b/crates/aether-data/adapters/postgres/migrations/20260903000000_add_routing_group_sort_order.sql index 32d62f170..b8a391020 100644 --- a/crates/aether-data/adapters/postgres/migrations/20260903000000_add_routing_group_sort_order.sql +++ b/crates/aether-data/adapters/postgres/migrations/20260903000000_add_routing_group_sort_order.sql @@ -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);