From 18bfd8391e3ead6bea5f5819e883050a31407758 Mon Sep 17 00:00:00 2001 From: NathanFlurry Date: Mon, 30 Sep 2024 12:09:41 +0000 Subject: [PATCH] fix(backend): fix apply migration file globs not working on windows (#532) --- packages/backend/toolchain/build/plan/project.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/backend/toolchain/build/plan/project.ts b/packages/backend/toolchain/build/plan/project.ts index 2d685076..4d623bdf 100644 --- a/packages/backend/toolchain/build/plan/project.ts +++ b/packages/backend/toolchain/build/plan/project.ts @@ -30,6 +30,7 @@ import { copy, exists } from "@std/fs"; import * as esbuild from "esbuild"; import { BACKEND_ROOT } from "../../utils/paths.ts"; +import { assert } from "@std/assert"; export async function planProjectBuild( buildState: BuildState, @@ -416,7 +417,12 @@ export async function planProjectBuild( // Run apply in parallel since it's non-interactive for (const module of applyMigrations) { - const migrations = await glob.glob(resolve(module.path, "db", "migrations", "*.sql")); + // List all migrations + const migrationsCwd = resolve(module.path, "db", "migrations") + const migrationsRelative = await glob.glob("*.sql", { cwd: migrationsCwd }); + assert(migrationsRelative.length > 0, `must have more than 1 migration for module ${module.name}`); + const migrations = migrationsRelative.map(x => resolve(migrationsCwd, x)); + buildStep(buildState, { id: `module.${module.name}.migrate.apply`, name: "Migrate Database",