From 85c2bd807ed5ccf3a1179f542f38c726baa697b3 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 1 Jun 2026 14:49:41 -0700 Subject: [PATCH] Handle the new added mode column --- server/setup/scriptsPg/1.19.0.ts | 9 +++++++++ server/setup/scriptsSqlite/1.19.0.ts | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/server/setup/scriptsPg/1.19.0.ts b/server/setup/scriptsPg/1.19.0.ts index 3691d43a0..7381a245e 100644 --- a/server/setup/scriptsPg/1.19.0.ts +++ b/server/setup/scriptsPg/1.19.0.ts @@ -164,6 +164,15 @@ export default async function migration() { await db.execute( sql`ALTER TABLE "resources" ADD COLUMN "mode" text DEFAULT 'http' NOT NULL;` ); + await db.execute(sql` + UPDATE "resources" + SET "mode" = CASE + WHEN COALESCE("http", true) = true THEN 'http' + WHEN COALESCE("http", false) = false AND LOWER(COALESCE("protocol", '')) = 'tcp' THEN 'tcp' + WHEN COALESCE("http", false) = false AND LOWER(COALESCE("protocol", '')) = 'udp' THEN 'udp' + ELSE 'http' + END; + `); await db.execute( sql`ALTER TABLE "resources" ADD COLUMN "pamMode" varchar(32) DEFAULT 'passthrough';` ); diff --git a/server/setup/scriptsSqlite/1.19.0.ts b/server/setup/scriptsSqlite/1.19.0.ts index bafcd8222..b1c8d347e 100644 --- a/server/setup/scriptsSqlite/1.19.0.ts +++ b/server/setup/scriptsSqlite/1.19.0.ts @@ -265,6 +265,17 @@ export default async function migration() { ALTER TABLE 'resources' ADD 'mode' text DEFAULT 'http' NOT NULL; ` ).run(); + db.prepare( + ` + UPDATE 'resources' + SET "mode" = CASE + WHEN COALESCE("http", 1) = 1 THEN 'http' + WHEN COALESCE("http", 0) = 0 AND LOWER(COALESCE("protocol", '')) = 'tcp' THEN 'tcp' + WHEN COALESCE("http", 0) = 0 AND LOWER(COALESCE("protocol", '')) = 'udp' THEN 'udp' + ELSE 'http' + END; + ` + ).run(); db.prepare( ` ALTER TABLE 'resources' ADD 'pamMode' text DEFAULT 'passthrough';