-import { logger } from '../helpers'
-
-function migrate (finalCallback: (err: Error) => void) {
- waterfall([
-
- function checkApplicationTableExists (callback) {
- db.sequelize.getQueryInterface().showAllTables().asCallback(function (err, tables) {
- if (err) return callback(err)
-
- // No tables, we don't need to migrate anything
- // The installer will do that
- if (tables.length === 0) return finalCallback(null)
-
- return callback(null)
- })
- },
-
- function loadMigrationVersion (callback) {
- db.Application.loadMigrationVersion(callback)
- },
-
- function createMigrationRowIfNotExists (actualVersion, callback) {
+import { logger, readdirPromise } from '../helpers'
+
+function migrate () {
+ const p = db.sequelize.getQueryInterface().showAllTables()
+ .then(tables => {
+ // No tables, we don't need to migrate anything
+ // The installer will do that
+ if (tables.length === 0) throw null
+ })
+ .then(() => {
+ return db.Application.loadMigrationVersion()
+ })
+ .then(actualVersion => {