'use strict'
const eachSeries = require('async/eachSeries')
-const mongoose = require('mongoose')
const path = require('path')
const constants = require('./constants')
+const db = require('./database')
const logger = require('../helpers/logger')
-const Application = mongoose.model('Application')
-
const migrator = {
migrate: migrate
}
function migrate (callback) {
- Application.loadMongoSchemaVersion(function (err, actualVersion) {
+ db.Application.loadSqlSchemaVersion(function (err, actualVersion) {
if (err) return callback(err)
// If there are a new mongo schemas
- if (!actualVersion || actualVersion < constants.LAST_MONGO_SCHEMA_VERSION) {
+ if (!actualVersion || actualVersion < constants.LAST_SQL_SCHEMA_VERSION) {
logger.info('Begin migrations.')
eachSeries(constants.MONGO_MIGRATION_SCRIPTS, function (entity, callbackEach) {
if (err) return callbackEach(err)
// Update the new mongo version schema
- Application.updateMongoSchemaVersion(versionScript, callbackEach)
+ db.Application.updateSqlSchemaVersion(versionScript, callbackEach)
})
}, function (err) {
if (err) return callback(err)
- logger.info('Migrations finished. New mongo version schema: %s', constants.LAST_MONGO_SCHEMA_VERSION)
+ logger.info('Migrations finished. New SQL version schema: %s', constants.LAST_SQL_SCHEMA_VERSION)
return callback(null)
})
} else {