mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-18 18:23:18 +02:00
Remove wrong named 1.21.1 migration for 1.22
This commit is contained in:
@@ -28,8 +28,7 @@ import m19 from "./scriptsPg/1.18.4";
|
|||||||
import m20 from "./scriptsPg/1.19.0";
|
import m20 from "./scriptsPg/1.19.0";
|
||||||
import m21 from "./scriptsPg/1.20.0";
|
import m21 from "./scriptsPg/1.20.0";
|
||||||
import m22 from "./scriptsPg/1.21.0";
|
import m22 from "./scriptsPg/1.21.0";
|
||||||
import m23 from "./scriptsPg/1.21.1";
|
import m23 from "./scriptsPg/1.22.0";
|
||||||
import m24 from "./scriptsPg/1.22.0";
|
|
||||||
|
|
||||||
// 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
|
||||||
@@ -58,8 +57,7 @@ const migrations = [
|
|||||||
{ version: "1.19.0", run: m20 },
|
{ version: "1.19.0", run: m20 },
|
||||||
{ version: "1.20.0", run: m21 },
|
{ version: "1.20.0", run: m21 },
|
||||||
{ version: "1.21.0", run: m22 },
|
{ version: "1.21.0", run: m22 },
|
||||||
{ version: "1.21.1", run: m23 },
|
{ version: "1.22.0", run: m23 }
|
||||||
{ version: "1.22.0", run: m24 }
|
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as {
|
] as {
|
||||||
version: string;
|
version: string;
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ import m41 from "./scriptsSqlite/1.19.0";
|
|||||||
import m42 from "./scriptsSqlite/1.19.1";
|
import m42 from "./scriptsSqlite/1.19.1";
|
||||||
import m43 from "./scriptsSqlite/1.20.0";
|
import m43 from "./scriptsSqlite/1.20.0";
|
||||||
import m44 from "./scriptsSqlite/1.21.0";
|
import m44 from "./scriptsSqlite/1.21.0";
|
||||||
import m45 from "./scriptsSqlite/1.21.1";
|
import m45 from "./scriptsSqlite/1.22.0";
|
||||||
import m46 from "./scriptsSqlite/1.22.0";
|
|
||||||
|
|
||||||
// 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
|
||||||
@@ -94,8 +93,7 @@ const migrations = [
|
|||||||
{ version: "1.19.1", run: m42 },
|
{ version: "1.19.1", run: m42 },
|
||||||
{ version: "1.20.0", run: m43 },
|
{ version: "1.20.0", run: m43 },
|
||||||
{ version: "1.21.0", run: m44 },
|
{ version: "1.21.0", run: m44 },
|
||||||
{ version: "1.21.1", run: m45 },
|
{ version: "1.22.0", run: m45 }
|
||||||
{ version: "1.22.0", run: m46 }
|
|
||||||
// Add new migrations here as they are created
|
// Add new migrations here as they are created
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,8 @@ import { fromZodError } from "zod-validation-error";
|
|||||||
|
|
||||||
const version = "1.22.0";
|
const version = "1.22.0";
|
||||||
|
|
||||||
|
const actionsToGrant = ["getSiteResource", "listSiteResources"] as const;
|
||||||
|
|
||||||
export default async function migration() {
|
export default async function migration() {
|
||||||
console.log(`Running setup script ${version}...`);
|
console.log(`Running setup script ${version}...`);
|
||||||
|
|
||||||
@@ -16,9 +18,23 @@ export default async function migration() {
|
|||||||
await db.execute(sql`BEGIN`);
|
await db.execute(sql`BEGIN`);
|
||||||
|
|
||||||
await db.execute(sql`
|
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`);
|
await db.execute(sql`COMMIT`);
|
||||||
console.log("Migrated database");
|
console.log("Migrated database");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,6 +8,8 @@ import { fromZodError } from "zod-validation-error";
|
|||||||
|
|
||||||
const version = "1.22.0";
|
const version = "1.22.0";
|
||||||
|
|
||||||
|
const actionsToGrant = ["getSiteResource", "listSiteResources"] as const;
|
||||||
|
|
||||||
export default async function migration() {
|
export default async function migration() {
|
||||||
console.log(`Running setup script ${version}...`);
|
console.log(`Running setup script ${version}...`);
|
||||||
|
|
||||||
@@ -22,6 +24,23 @@ export default async function migration() {
|
|||||||
`
|
`
|
||||||
`
|
`
|
||||||
).run();
|
).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");
|
db.pragma("foreign_keys = ON");
|
||||||
|
|||||||
Reference in New Issue
Block a user