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
+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) {