Handle the new added mode column

This commit is contained in:
Owen
2026-06-01 14:49:41 -07:00
parent 517e1d15c8
commit 85c2bd807e
2 changed files with 20 additions and 0 deletions

View File

@@ -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';