forked from adonisjs/lucid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMigrationStatus.js
59 lines (53 loc) · 1.23 KB
/
MigrationStatus.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict'
/*
* adonis-lucid
*
* (c) Harminder Virk <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
const BaseMigration = require('./BaseMigration')
class MigrationStatus extends BaseMigration {
/**
* Command signature required by ace
*
* @method signature
*
* @return {String}
*/
static get signature () {
return 'migration:status'
}
/**
* Command description
*
* @method description
*
* @return {String}
*/
static get description () {
return 'Check migrations current status'
}
/**
* Method called when command is executed. This method
* will print a table with the migrations status.
*
* @method handle
*
* @return {void|Array}
*/
async handle () {
try {
const migrations = await this.migration.status(this._getSchemaFiles())
const head = ['File name', 'Migrated', 'Batch']
const body = migrations.map((migration) => {
return [migration.name, migration.migrated ? 'Yes' : 'No', migration.batch || '']
})
this.table(head, body)
} catch (error) {
console.log(error)
}
}
}
module.exports = MigrationStatus