-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Josh Calder
committed
Dec 13, 2022
1 parent
7a4837d
commit db93d6d
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { runMigrateWithDbUrl, withMigrate } from '../../lib/migrations'; | ||
import { loadBuiltConfig } from '../../lib/config/loadConfig'; | ||
import { ExitError } from '../utils'; | ||
import { getSchemaPaths } from '../../artifacts'; | ||
|
||
export async function checkMigrations(cwd: string) { | ||
const config = loadBuiltConfig(cwd); | ||
await withMigrate(getSchemaPaths(cwd).prisma, async migrate => { | ||
const evaluateDataLossResult = await runMigrateWithDbUrl( | ||
config.db.url, | ||
config.db.shadowDatabaseUrl, | ||
() => migrate.evaluateDataLoss() | ||
); | ||
if (evaluateDataLossResult.migrationSteps) { | ||
console.log('Migrations are out of date - run `keystone migrate generate` to update them'); | ||
throw new ExitError(1); | ||
} else { | ||
console.log('✅ Migrations are up to date'); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters