From 0059b21db6f00388b4de9826f45bc990a26b370e Mon Sep 17 00:00:00 2001 From: Mike Swanson Date: Mon, 1 Jun 2026 10:05:38 -0700 Subject: [PATCH] =?UTF-8?q?fix(server):=20revert=20migration=20008=20comme?= =?UTF-8?q?nt=20edit=20=E2=80=94=20modifying=20an=20applied=20sqlx=20migra?= =?UTF-8?q?tion=20breaks=20its=20checksum=20and=20crash-loops=20the=20serv?= =?UTF-8?q?er=20on=20startup;=20machines.rs=20ON=20CONFLICT=20fix=20retain?= =?UTF-8?q?ed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/migrations/008_machine_uid.sql | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/server/migrations/008_machine_uid.sql b/server/migrations/008_machine_uid.sql index 3af40f3..8488031 100644 --- a/server/migrations/008_machine_uid.sql +++ b/server/migrations/008_machine_uid.sql @@ -34,12 +34,8 @@ ALTER TABLE connect_machines ADD COLUMN IF NOT EXISTS machine_uid TEXT; -- 2. Enforce one row per machine_uid, but ONLY for rows that actually have one. -- A partial UNIQUE index (WHERE machine_uid IS NOT NULL) lets unlimited legacy --- NULL rows coexist while making a non-null machine_uid a true dedup key. Because --- this index is PARTIAL, Postgres only binds an ON CONFLICT inference clause to it --- when the clause REPEATS the same predicate: upsert_machine's arbiter must be --- `ON CONFLICT (machine_uid) WHERE machine_uid IS NOT NULL` (a bare --- `ON CONFLICT (machine_uid)` raises "no unique or exclusion constraint matching --- the ON CONFLICT specification" at runtime and persists no row). +-- NULL rows coexist while making a non-null machine_uid a true dedup key — this +-- is what upsert_machine's `ON CONFLICT (machine_uid)` arbiter binds to. CREATE UNIQUE INDEX IF NOT EXISTS idx_connect_machines_machine_uid ON connect_machines (machine_uid) WHERE machine_uid IS NOT NULL;