Skip to content

Commit

Permalink
fix(db push): make sure to stop migrate engine when it errors
Browse files Browse the repository at this point in the history
Related
#7795
#7990
  • Loading branch information
Jolg42 committed Jul 7, 2021
1 parent 1761d6a commit fdee7e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/packages/migrate/package.json
Expand Up @@ -74,7 +74,7 @@
"format": "prettier --write .",
"lint": "eslint --cache --fix --ext .ts .",
"lint-ci": "eslint --ext .ts .",
"test": "jest --forceExit",
"test": "jest",
"build": "tsc -d -p tsconfig.build.json",
"prepublishOnly": "pnpm run build"
},
Expand Down
13 changes: 10 additions & 3 deletions src/packages/migrate/src/commands/DbPush.ts
Expand Up @@ -21,6 +21,7 @@ import {
NoSchemaFoundError,
} from '../utils/errors'
import { printDatasource } from '../utils/printDatasource'
import { EngineResults } from '../types'

export class DbPush implements Command {
public static new(): DbPush {
Expand Down Expand Up @@ -136,9 +137,15 @@ You can now remove the ${chalk.red('--preview-feature')} flag.`)
}

const before = Date.now()
const migration = await migrate.push({
force: args['--accept-data-loss'],
})
let migration: EngineResults.SchemaPush
try {
migration = await migrate.push({
force: args['--accept-data-loss'],
})
} catch (e) {
migrate.stop()
throw e
}

if (migration.unexecutable && migration.unexecutable.length > 0) {
const messages: string[] = []
Expand Down

0 comments on commit fdee7e9

Please sign in to comment.