From 3eaca924dab126fd0289ac2ef8eefa44bec0c24b Mon Sep 17 00:00:00 2001 From: Owen Date: Thu, 11 Sep 2025 21:28:15 -0700 Subject: [PATCH] Update migrations --- server/setup/scriptsPg/1.10.0.ts | 32 ++++++++++++++++++++++------ server/setup/scriptsSqlite/1.10.0.ts | 19 +++++++++++------ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/server/setup/scriptsPg/1.10.0.ts b/server/setup/scriptsPg/1.10.0.ts index f33906cf..7cb1fa5a 100644 --- a/server/setup/scriptsPg/1.10.0.ts +++ b/server/setup/scriptsPg/1.10.0.ts @@ -16,13 +16,31 @@ export default async function migration() { await db.execute(sql`BEGIN`); - await db.execute(sql`ALTER TABLE "exitNodes" ADD COLUMN "region" text;`); - - await db.execute(sql`ALTER TABLE "idpOidcConfig" ADD COLUMN "variant" text DEFAULT 'oidc' NOT NULL;`); - - await db.execute(sql`ALTER TABLE "resources" ADD COLUMN "niceId" text DEFAULT '' NOT NULL;`); - - await db.execute(sql`ALTER TABLE "userOrgs" ADD COLUMN "autoProvisioned" boolean DEFAULT false;`); + await db.execute( + sql`ALTER TABLE "exitNodes" ADD COLUMN "region" text;` + ); + + await db.execute( + sql`ALTER TABLE "idpOidcConfig" ADD COLUMN "variant" text DEFAULT 'oidc' NOT NULL;` + ); + + await db.execute( + sql`ALTER TABLE "resources" ADD COLUMN "niceId" text DEFAULT '' NOT NULL;` + ); + + await db.execute( + sql`ALTER TABLE "userOrgs" ADD COLUMN "autoProvisioned" boolean DEFAULT false;` + ); + + await db.execute( + sql`ALTER TABLE "targets" ADD COLUMN "pathMatchType" text;` + ); + + await db.execute(sql`ALTER TABLE "targets" ADD COLUMN "path" text;`); + + await db.execute( + sql`ALTER TABLE "resources" ADD COLUMN "headers" text;` + ); const usedNiceIds: string[] = []; diff --git a/server/setup/scriptsSqlite/1.10.0.ts b/server/setup/scriptsSqlite/1.10.0.ts index f5f6c3a3..359e80e1 100644 --- a/server/setup/scriptsSqlite/1.10.0.ts +++ b/server/setup/scriptsSqlite/1.10.0.ts @@ -12,14 +12,14 @@ export default async function migration() { const db = new Database(location); const resourceSiteMap = new Map(); - const firstSiteId: number = 1; + const firstSiteId: number = 1; try { - const resources = db - .prepare( - "SELECT resourceId FROM resources WHERE siteId IS NOT NULL" - ) - .all() as Array<{ resourceId: number; }>; + const resources = db + .prepare( + "SELECT resourceId FROM resources WHERE siteId IS NOT NULL" + ) + .all() as Array<{ resourceId: number }>; db.transaction(() => { db.exec(` @@ -27,6 +27,9 @@ export default async function migration() { ALTER TABLE 'idpOidcConfig' ADD 'variant' text DEFAULT 'oidc' NOT NULL; ALTER TABLE 'resources' ADD 'niceId' text DEFAULT '' NOT NULL; ALTER TABLE 'userOrgs' ADD 'autoProvisioned' integer DEFAULT false; + ALTER TABLE 'targets' ADD 'pathMatchType' text; + ALTER TABLE 'targets' ADD 'path' text; + ALTER TABLE 'resources' ADD 'headers' text; `); // this diverges from the schema a bit because the schema does not have a default on niceId but was required for the migration and I dont think it will effect much down the line... const usedNiceIds: string[] = []; @@ -47,7 +50,9 @@ export default async function migration() { } loops++; } - db.prepare(`UPDATE resources SET niceId = ? WHERE resourceId = ?`).run(niceId, resourceId.resourceId); + db.prepare( + `UPDATE resources SET niceId = ? WHERE resourceId = ?` + ).run(niceId, resourceId.resourceId); } })();