Skip to content

Commit

Permalink
fix(db push): make sure to stop migrate engine when it errors (#8149)
Browse files Browse the repository at this point in the history
* fix(db push): make sure to stop migrate engine when it errors

Related
#7795
#7990

* Restore package.json
  • Loading branch information
Jolg42 committed Jul 8, 2021
1 parent 7e75286 commit 8898470
Showing 1 changed file with 10 additions and 3 deletions.
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 @@ -135,9 +136,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 8898470

Please sign in to comment.