aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrator.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrator.js')
-rw-r--r--server/initializers/migrator.js12
1 files changed, 5 insertions, 7 deletions
diff --git a/server/initializers/migrator.js b/server/initializers/migrator.js
index 6b31d994f..9e5350e60 100644
--- a/server/initializers/migrator.js
+++ b/server/initializers/migrator.js
@@ -1,24 +1,22 @@
1'use strict' 1'use strict'
2 2
3const eachSeries = require('async/eachSeries') 3const eachSeries = require('async/eachSeries')
4const mongoose = require('mongoose')
5const path = require('path') 4const path = require('path')
6 5
7const constants = require('./constants') 6const constants = require('./constants')
7const db = require('./database')
8const logger = require('../helpers/logger') 8const logger = require('../helpers/logger')
9 9
10const Application = mongoose.model('Application')
11
12const migrator = { 10const migrator = {
13 migrate: migrate 11 migrate: migrate
14} 12}
15 13
16function migrate (callback) { 14function migrate (callback) {
17 Application.loadMongoSchemaVersion(function (err, actualVersion) { 15 db.Application.loadSqlSchemaVersion(function (err, actualVersion) {
18 if (err) return callback(err) 16 if (err) return callback(err)
19 17
20 // If there are a new mongo schemas 18 // If there are a new mongo schemas
21 if (!actualVersion || actualVersion < constants.LAST_MONGO_SCHEMA_VERSION) { 19 if (!actualVersion || actualVersion < constants.LAST_SQL_SCHEMA_VERSION) {
22 logger.info('Begin migrations.') 20 logger.info('Begin migrations.')
23 21
24 eachSeries(constants.MONGO_MIGRATION_SCRIPTS, function (entity, callbackEach) { 22 eachSeries(constants.MONGO_MIGRATION_SCRIPTS, function (entity, callbackEach) {
@@ -36,12 +34,12 @@ function migrate (callback) {
36 if (err) return callbackEach(err) 34 if (err) return callbackEach(err)
37 35
38 // Update the new mongo version schema 36 // Update the new mongo version schema
39 Application.updateMongoSchemaVersion(versionScript, callbackEach) 37 db.Application.updateSqlSchemaVersion(versionScript, callbackEach)
40 }) 38 })
41 }, function (err) { 39 }, function (err) {
42 if (err) return callback(err) 40 if (err) return callback(err)
43 41
44 logger.info('Migrations finished. New mongo version schema: %s', constants.LAST_MONGO_SCHEMA_VERSION) 42 logger.info('Migrations finished. New SQL version schema: %s', constants.LAST_SQL_SCHEMA_VERSION)
45 return callback(null) 43 return callback(null)
46 }) 44 })
47 } else { 45 } else {