/
rollback.ts
43 lines (31 loc) · 944 Bytes
/
rollback.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import cli from 'cli-ux'
import {Command, flags} from '@oclif/command'
import {MongoMigrateRc} from '../config/mongo-migrate-rc'
import File from '../helpers/file'
export default class Rollback extends Command {
private rootPath = ''
static description = 'command to rollback migrations files'
static examples = [
'$ mongo-migrate rollback',
]
static flags = {
help: flags.help({char: 'h'}),
tenant: flags.string({
char: 't',
description: 'tenant file to connect',
multiple: true,
}),
}
async run() {
cli.action.start('starting', 'loading', {stdout: true})
cli.action.stop()
const {flags} = this.parse(Rollback)
const mongoMigrateRc = new MongoMigrateRc()
const file = new File(
await mongoMigrateRc.getConfigFile()
)
await file.execute('rollback', flags.tenant)
cli.action.start('stoping', 'loading', {stdout: true})
cli.action.stop()
}
}