Server: fix migrations with an empty Applications table
This commit is contained in:
parent
4b4660582b
commit
ed708d62a6
|
@ -32,6 +32,18 @@ function migrate (finalCallback) {
|
||||||
db.Application.loadMigrationVersion(callback)
|
db.Application.loadMigrationVersion(callback)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
function createMigrationRowIfNotExists (actualVersion, callback) {
|
||||||
|
if (actualVersion === null) {
|
||||||
|
db.Application.create({
|
||||||
|
migrationVersion: 0
|
||||||
|
}, function (err) {
|
||||||
|
return callabck(err, 0)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return callback(null, actualVersion)
|
||||||
|
},
|
||||||
|
|
||||||
function abortMigrationIfNotNeeded (actualVersion, callback) {
|
function abortMigrationIfNotNeeded (actualVersion, callback) {
|
||||||
// No need migrations
|
// No need migrations
|
||||||
if (actualVersion >= constants.LAST_MIGRATION_VERSION) return finalCallback(null)
|
if (actualVersion >= constants.LAST_MIGRATION_VERSION) return finalCallback(null)
|
||||||
|
|
|
@ -31,7 +31,7 @@ function loadMigrationVersion (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.findOne(query).asCallback(function (err, data) {
|
return this.findOne(query).asCallback(function (err, data) {
|
||||||
const version = data ? data.migrationVersion : 0
|
const version = data ? data.migrationVersion : null
|
||||||
|
|
||||||
return callback(err, version)
|
return callback(err, version)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue