diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/migrator.js | 12 | ||||
-rw-r--r-- | server/models/application.js | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/server/initializers/migrator.js b/server/initializers/migrator.js index 8c67903ad..0f25a23d1 100644 --- a/server/initializers/migrator.js +++ b/server/initializers/migrator.js | |||
@@ -32,6 +32,18 @@ function migrate (finalCallback) { | |||
32 | db.Application.loadMigrationVersion(callback) | 32 | db.Application.loadMigrationVersion(callback) |
33 | }, | 33 | }, |
34 | 34 | ||
35 | function createMigrationRowIfNotExists (actualVersion, callback) { | ||
36 | if (actualVersion === null) { | ||
37 | db.Application.create({ | ||
38 | migrationVersion: 0 | ||
39 | }, function (err) { | ||
40 | return callabck(err, 0) | ||
41 | }) | ||
42 | } | ||
43 | |||
44 | return callback(null, actualVersion) | ||
45 | }, | ||
46 | |||
35 | function abortMigrationIfNotNeeded (actualVersion, callback) { | 47 | function abortMigrationIfNotNeeded (actualVersion, callback) { |
36 | // No need migrations | 48 | // No need migrations |
37 | if (actualVersion >= constants.LAST_MIGRATION_VERSION) return finalCallback(null) | 49 | if (actualVersion >= constants.LAST_MIGRATION_VERSION) return finalCallback(null) |
diff --git a/server/models/application.js b/server/models/application.js index 46dcfde33..64e1a0540 100644 --- a/server/models/application.js +++ b/server/models/application.js | |||
@@ -31,7 +31,7 @@ function loadMigrationVersion (callback) { | |||
31 | } | 31 | } |
32 | 32 | ||
33 | return this.findOne(query).asCallback(function (err, data) { | 33 | return this.findOne(query).asCallback(function (err, data) { |
34 | const version = data ? data.migrationVersion : 0 | 34 | const version = data ? data.migrationVersion : null |
35 | 35 | ||
36 | return callback(err, version) | 36 | return callback(err, version) |
37 | }) | 37 | }) |