Remove wrong named 1.21.1 migration for 1.22

This commit is contained in:
Owen
2026-08-17 16:01:30 -04:00
parent 075d112861
commit 92916cd9db
6 changed files with 40 additions and 89 deletions
+2 -4
View File
@@ -28,8 +28,7 @@ import m19 from "./scriptsPg/1.18.4";
import m20 from "./scriptsPg/1.19.0";
import m21 from "./scriptsPg/1.20.0";
import m22 from "./scriptsPg/1.21.0";
import m23 from "./scriptsPg/1.21.1";
import m24 from "./scriptsPg/1.22.0";
import m23 from "./scriptsPg/1.22.0";
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
// EXCEPT FOR THE DATABASE AND THE SCHEMA
@@ -58,8 +57,7 @@ const migrations = [
{ version: "1.19.0", run: m20 },
{ version: "1.20.0", run: m21 },
{ version: "1.21.0", run: m22 },
{ version: "1.21.1", run: m23 },
{ version: "1.22.0", run: m24 }
{ version: "1.22.0", run: m23 }
// Add new migrations here as they are created
] as {
version: string;
+2 -4
View File
@@ -47,8 +47,7 @@ import m41 from "./scriptsSqlite/1.19.0";
import m42 from "./scriptsSqlite/1.19.1";
import m43 from "./scriptsSqlite/1.20.0";
import m44 from "./scriptsSqlite/1.21.0";
import m45 from "./scriptsSqlite/1.21.1";
import m46 from "./scriptsSqlite/1.22.0";
import m45 from "./scriptsSqlite/1.22.0";
// THIS CANNOT IMPORT ANYTHING FROM THE SERVER
// EXCEPT FOR THE DATABASE AND THE SCHEMA
@@ -94,8 +93,7 @@ const migrations = [
{ version: "1.19.1", run: m42 },
{ version: "1.20.0", run: m43 },
{ version: "1.21.0", run: m44 },
{ version: "1.21.1", run: m45 },
{ version: "1.22.0", run: m46 }
{ version: "1.22.0", run: m45 }
// Add new migrations here as they are created
] as const;
-37
View File
@@ -1,37 +0,0 @@
import { db } from "@server/db/pg/driver";
import { sql } from "drizzle-orm";
const version = "1.21.1";
const actionsToGrant = ["getSiteResource", "listSiteResources"] as const;
export default async function migration() {
console.log(`Running setup script ${version}...`);
try {
await db.execute(sql`BEGIN`);
for (const actionId of actionsToGrant) {
await db.execute(sql`
INSERT INTO "roleActions" ("roleId", "actionId", "orgId")
SELECT r."roleId", ${actionId}, r."orgId"
FROM "roles" r
WHERE COALESCE(r."isAdmin", false) = false
AND NOT EXISTS (
SELECT 1 FROM "roleActions" ra
WHERE ra."roleId" = r."roleId"
AND ra."actionId" = ${actionId}
AND ra."orgId" = r."orgId"
);
`);
}
await db.execute(sql`COMMIT`);
console.log(`Finished setup script ${version}`);
} catch (e) {
await db.execute(sql`ROLLBACK`);
console.log("Unable to migrate database");
console.log(e);
throw e;
}
}
+17 -1
View File
@@ -9,6 +9,8 @@ import { fromZodError } from "zod-validation-error";
const version = "1.22.0";
const actionsToGrant = ["getSiteResource", "listSiteResources"] as const;
export default async function migration() {
console.log(`Running setup script ${version}...`);
@@ -16,9 +18,23 @@ export default async function migration() {
await db.execute(sql`BEGIN`);
await db.execute(sql`
`);
for (const actionId of actionsToGrant) {
await db.execute(sql`
INSERT INTO "roleActions" ("roleId", "actionId", "orgId")
SELECT r."roleId", ${actionId}, r."orgId"
FROM "roles" r
WHERE COALESCE(r."isAdmin", false) = false
AND NOT EXISTS (
SELECT 1 FROM "roleActions" ra
WHERE ra."roleId" = r."roleId"
AND ra."actionId" = ${actionId}
AND ra."orgId" = r."orgId"
);
`);
}
await db.execute(sql`COMMIT`);
console.log("Migrated database");
} catch (e) {
-43
View File
@@ -1,43 +0,0 @@
import { APP_PATH } from "@server/lib/consts";
import Database from "better-sqlite3";
import path from "path";
const version = "1.21.1";
const actionsToGrant = ["getSiteResource", "listSiteResources"] as const;
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(() => {
const insertRoleAction = db.prepare(`
INSERT INTO 'roleActions' ("roleId", "actionId", "orgId")
SELECT r."roleId", ?, r."orgId"
FROM 'roles' r
WHERE COALESCE(r."isAdmin", 0) = 0
AND NOT EXISTS (
SELECT 1 FROM 'roleActions' ra
WHERE ra."roleId" = r."roleId"
AND ra."actionId" = ?
AND ra."orgId" = r."orgId"
);
`);
for (const actionId of actionsToGrant) {
insertRoleAction.run(actionId, actionId);
}
})();
console.log(`Finished setup script ${version}`);
} catch (e) {
console.log("Unable to migrate database");
console.log(e);
throw e;
} finally {
db.close();
}
}
+19
View File
@@ -8,6 +8,8 @@ import { fromZodError } from "zod-validation-error";
const version = "1.22.0";
const actionsToGrant = ["getSiteResource", "listSiteResources"] as const;
export default async function migration() {
console.log(`Running setup script ${version}...`);
@@ -22,6 +24,23 @@ export default async function migration() {
`
`
).run();
const insertRoleAction = db.prepare(`
INSERT INTO 'roleActions' ("roleId", "actionId", "orgId")
SELECT r."roleId", ?, r."orgId"
FROM 'roles' r
WHERE COALESCE(r."isAdmin", 0) = 0
AND NOT EXISTS (
SELECT 1 FROM 'roleActions' ra
WHERE ra."roleId" = r."roleId"
AND ra."actionId" = ?
AND ra."orgId" = r."orgId"
);
`);
for (const actionId of actionsToGrant) {
insertRoleAction.run(actionId, actionId);
}
})();
db.pragma("foreign_keys = ON");