diff --git a/install/main.go b/install/main.go index 42bd621d..1f7213a1 100644 --- a/install/main.go +++ b/install/main.go @@ -220,7 +220,7 @@ func main() { } } - if !config.HybridMode && checkIsPangolinInstalledWithHybrid() { + if !config.HybridMode { // Setup Token Section fmt.Println("\n=== Setup Token ===") diff --git a/server/lib/consts.ts b/server/lib/consts.ts index 30efc07e..506c1c8d 100644 --- a/server/lib/consts.ts +++ b/server/lib/consts.ts @@ -2,7 +2,7 @@ import path from "path"; import { fileURLToPath } from "url"; // This is a placeholder value replaced by the build process -export const APP_VERSION = "1.10.0"; +export const APP_VERSION = "1.10.1"; export const __FILENAME = fileURLToPath(import.meta.url); export const __DIRNAME = path.dirname(__FILENAME); diff --git a/server/setup/migrationsSqlite.ts b/server/setup/migrationsSqlite.ts index 79a7d0ab..b8fa64f0 100644 --- a/server/setup/migrationsSqlite.ts +++ b/server/setup/migrationsSqlite.ts @@ -27,6 +27,7 @@ import m22 from "./scriptsSqlite/1.7.0"; import m23 from "./scriptsSqlite/1.8.0"; import m24 from "./scriptsSqlite/1.9.0"; import m25 from "./scriptsSqlite/1.10.0"; +import m26 from "./scriptsSqlite/1.10.1"; // THIS CANNOT IMPORT ANYTHING FROM THE SERVER // EXCEPT FOR THE DATABASE AND THE SCHEMA @@ -53,6 +54,7 @@ const migrations = [ { version: "1.8.0", run: m23 }, { version: "1.9.0", run: m24 }, { version: "1.10.0", run: m25 }, + { version: "1.10.1", run: m26 }, // Add new migrations here as they are created ] as const; diff --git a/server/setup/scriptsSqlite/1.10.1.ts b/server/setup/scriptsSqlite/1.10.1.ts new file mode 100644 index 00000000..3608e92e --- /dev/null +++ b/server/setup/scriptsSqlite/1.10.1.ts @@ -0,0 +1,69 @@ +import { APP_PATH } from "@server/lib/consts"; +import Database from "better-sqlite3"; +import path from "path"; + +const version = "1.10.1"; + +export default async function migration() { + console.log(`Running setup script ${version}...`); + + const location = path.join(APP_PATH, "db", "db.sqlite"); + const db = new Database(location); + + try { + db.pragma("foreign_keys = OFF"); + + db.transaction(() => { + db.exec(`ALTER TABLE "targets" RENAME TO "targets_old"; +--> statement-breakpoint +CREATE TABLE "targets" ( + "targetId" INTEGER PRIMARY KEY AUTOINCREMENT, + "resourceId" INTEGER NOT NULL, + "siteId" INTEGER NOT NULL, + "ip" TEXT NOT NULL, + "method" TEXT, + "port" INTEGER NOT NULL, + "internalPort" INTEGER, + "enabled" INTEGER NOT NULL DEFAULT 1, + "path" TEXT, + "pathMatchType" TEXT, + FOREIGN KEY ("resourceId") REFERENCES "resources"("resourceId") ON UPDATE no action ON DELETE cascade, + FOREIGN KEY ("siteId") REFERENCES "sites"("siteId") ON UPDATE no action ON DELETE cascade +); +--> statement-breakpoint +INSERT INTO "targets" ( + "targetId", + "resourceId", + "siteId", + "ip", + "method", + "port", + "internalPort", + "enabled", + "path", + "pathMatchType" +) +SELECT + targetId, + resourceId, + siteId, + ip, + method, + port, + internalPort, + enabled, + path, + pathMatchType +FROM "targets_old"; +--> statement-breakpoint +DROP TABLE "targets_old";`); + })(); + + db.pragma("foreign_keys = ON"); + + console.log(`Migrated database`); + } catch (e) { + console.log("Failed to migrate db:", e); + throw e; + } +}