From c3ce0da37c78c4e1174a13e8d34d00a4f6079dcb Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Wed, 1 Mar 2023 19:09:46 -0500 Subject: [PATCH] Fix behavior of `keystone start --with-migrations` (#8354) Co-authored-by: Josh Calder --- .changeset/tidy-keys-own.md | 5 +++++ packages/core/src/lib/migrations.ts | 4 ++-- packages/core/src/scripts/run/start.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/tidy-keys-own.md diff --git a/.changeset/tidy-keys-own.md b/.changeset/tidy-keys-own.md new file mode 100644 index 00000000000..523c827de54 --- /dev/null +++ b/.changeset/tidy-keys-own.md @@ -0,0 +1,5 @@ +--- +'@keystone-6/core': patch +--- + +Fixes behavior of `keystone start --with-migrations` diff --git a/packages/core/src/lib/migrations.ts b/packages/core/src/lib/migrations.ts index 5e8402d7f7e..badf3572395 100644 --- a/packages/core/src/lib/migrations.ts +++ b/packages/core/src/lib/migrations.ts @@ -165,8 +165,8 @@ function logWarnings(warnings: string[]) { } } -export async function deployMigrations(dbUrl: string) { - return withMigrate(process.cwd(), async migrate => { +export async function deployMigrations(schemaPath: string, dbUrl: string) { + return withMigrate(schemaPath, async migrate => { const before = Date.now(); const migration = await runMigrateWithDbUrl(dbUrl, undefined, () => migrate.applyMigrations()); if (migration.appliedMigrationNames.length === 0) { diff --git a/packages/core/src/scripts/run/start.ts b/packages/core/src/scripts/run/start.ts index 34040b2454f..7269817870e 100644 --- a/packages/core/src/scripts/run/start.ts +++ b/packages/core/src/scripts/run/start.ts @@ -34,7 +34,7 @@ export const start = async ( await keystone.connect(); if (withMigrations) { console.log('✨ Applying database migrations'); - await deployMigrations(config.db.url); + await deployMigrations(paths.schema.prisma, config.db.url); } console.log('✨ Creating server');