Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
refactor(database): streamline migrateDb and run space role backfill
Richie McIlroy1caab2939225
diff --git a/packages/database/migrate.ts b/packages/database/migrate.tsindex de41fdc56..881e93d9f 100644--- a/packages/database/migrate.ts+++ b/packages/database/migrate.ts@@ -4,9 +4,10 @@ import { DrizzleQueryError } from "drizzle-orm";import { migrate } from "drizzle-orm/mysql2/migrator";import { runOrgIdBackfill } from "./migrations/orgid_backfill.ts";+import { runSpaceMemberRoleBackfill } from "./migrations/space_member_role_backfill.ts";async function runMigrate() {- await migrate(db() as any, {+ await migrate(db(), {migrationsFolder: path.join(process.cwd(), "/migrations"),});}@@ -20,19 +21,26 @@ function errorIsOrgIdMigration(e: unknown): e is DrizzleQueryError {}export async function migrateDb() {- runMigrate()- .catch(async (e) => {- if (errorIsOrgIdMigration(e)) {- console.log("non-null videos.orgId migration failed, running backfill");-- await runOrgIdBackfill();- await runMigrate();- } else throw e;- })- .catch((e) => {- if (errorIsOrgIdMigration(e))+ try {+ await runMigrate();+ } catch (e) {+ if (!errorIsOrgIdMigration(e)) throw e;++ console.log("non-null videos.orgId migration failed, running backfill");++ await runOrgIdBackfill();++ try {+ await runMigrate();+ } catch (retryError) {+ if (errorIsOrgIdMigration(retryError)) {throw new Error("videos.orgId backfill failed, you will need to manually update the videos.orgId column before attempting to migrate again.",);- });+ }+ throw retryError;+ }+ }++ await runSpaceMemberRoleBackfill();}