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) {
// No need migrations
if (actualVersion >= constants.LAST_MIGRATION_VERSION) return finalCallback(null)
}
return this.findOne(query).asCallback(function (err, data) {
- const version = data ? data.migrationVersion : 0
+ const version = data ? data.migrationVersion : null
return callback(err, version)
})