mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-06 18:56:39 +00:00
Add migrations for 1.15.3
This commit is contained in:
@@ -17,6 +17,7 @@ import m9 from "./scriptsPg/1.12.0";
|
|||||||
import m10 from "./scriptsPg/1.13.0";
|
import m10 from "./scriptsPg/1.13.0";
|
||||||
import m11 from "./scriptsPg/1.14.0";
|
import m11 from "./scriptsPg/1.14.0";
|
||||||
import m12 from "./scriptsPg/1.15.0";
|
import m12 from "./scriptsPg/1.15.0";
|
||||||
|
import m13 from "./scriptsPg/1.15.3";
|
||||||
|
|
||||||
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
||||||
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
||||||
@@ -34,7 +35,8 @@ const migrations = [
|
|||||||
{ version: "1.12.0", run: m9 },
|
{ version: "1.12.0", run: m9 },
|
||||||
{ version: "1.13.0", run: m10 },
|
{ version: "1.13.0", run: m10 },
|
||||||
{ version: "1.14.0", run: m11 },
|
{ version: "1.14.0", run: m11 },
|
||||||
{ version: "1.15.0", run: m12 }
|
{ version: "1.15.0", run: m12 },
|
||||||
|
{ version: "1.15.3", run: m13 }
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as {
|
] as {
|
||||||
version: string;
|
version: string;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import m30 from "./scriptsSqlite/1.12.0";
|
|||||||
import m31 from "./scriptsSqlite/1.13.0";
|
import m31 from "./scriptsSqlite/1.13.0";
|
||||||
import m32 from "./scriptsSqlite/1.14.0";
|
import m32 from "./scriptsSqlite/1.14.0";
|
||||||
import m33 from "./scriptsSqlite/1.15.0";
|
import m33 from "./scriptsSqlite/1.15.0";
|
||||||
|
import m34 from "./scriptsSqlite/1.15.3";
|
||||||
|
|
||||||
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
|
||||||
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
// EXCEPT FOR THE DATABASE AND THE SCHEMA
|
||||||
@@ -68,7 +69,8 @@ const migrations = [
|
|||||||
{ version: "1.12.0", run: m30 },
|
{ version: "1.12.0", run: m30 },
|
||||||
{ version: "1.13.0", run: m31 },
|
{ version: "1.13.0", run: m31 },
|
||||||
{ version: "1.14.0", run: m32 },
|
{ version: "1.14.0", run: m32 },
|
||||||
{ version: "1.15.0", run: m33 }
|
{ version: "1.15.0", run: m33 },
|
||||||
|
{ version: "1.15.3", run: m34 }
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|||||||
39
server/setup/scriptsPg/1.15.3.ts
Normal file
39
server/setup/scriptsPg/1.15.3.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { db } from "@server/db/pg/driver";
|
||||||
|
import { sql } from "drizzle-orm";
|
||||||
|
import { __DIRNAME } from "@server/lib/consts";
|
||||||
|
|
||||||
|
const version = "1.15.3";
|
||||||
|
|
||||||
|
export default async function migration() {
|
||||||
|
console.log(`Running setup script ${version}...`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await db.execute(sql`BEGIN`);
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "limits" ADD COLUMN "override" boolean DEFAULT false;`
|
||||||
|
);
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "subscriptionItems" ADD COLUMN "stripeSubscriptionItemId" varchar(255);`
|
||||||
|
);
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "subscriptionItems" ADD COLUMN "featureId" varchar(255);`
|
||||||
|
);
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "subscriptions" ADD COLUMN "version" integer;`
|
||||||
|
);
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "subscriptions" ADD COLUMN "type" varchar(50);`
|
||||||
|
);
|
||||||
|
|
||||||
|
await db.execute(sql`COMMIT`);
|
||||||
|
console.log("Migrated database");
|
||||||
|
} catch (e) {
|
||||||
|
await db.execute(sql`ROLLBACK`);
|
||||||
|
console.log("Unable to migrate database");
|
||||||
|
console.log(e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`${version} migration complete`);
|
||||||
|
}
|
||||||
28
server/setup/scriptsSqlite/1.15.3.ts
Normal file
28
server/setup/scriptsSqlite/1.15.3.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { __DIRNAME, APP_PATH } from "@server/lib/consts";
|
||||||
|
import Database from "better-sqlite3";
|
||||||
|
import path from "path";
|
||||||
|
|
||||||
|
const version = "1.15.3";
|
||||||
|
|
||||||
|
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.transaction(() => {
|
||||||
|
db.prepare(`ALTER TABLE 'limits' ADD 'override' integer DEFAULT false;`).run();
|
||||||
|
db.prepare(`ALTER TABLE 'subscriptionItems' ADD 'featureId' text;`).run();
|
||||||
|
db.prepare(`ALTER TABLE 'subscriptions' ADD 'version' integer;`).run();
|
||||||
|
db.prepare(`ALTER TABLE 'subscriptions' ADD 'type' text;`).run();
|
||||||
|
})();
|
||||||
|
|
||||||
|
console.log(`Migrated database`);
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Failed to migrate db:", e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`${version} migration complete`);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user