aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrator.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-12-11 21:50:51 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-12-19 21:22:28 +0100
commitfeb4bdfd9b46e87aadfa7c0d5338cde887d1f58c (patch)
tree2abc9fbc9569760e218fd52835850b757344b420 /server/initializers/migrator.js
parent108626609eda75e4ecc0a83a650a4d53c46220e0 (diff)
downloadPeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.gz
PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.tar.zst
PeerTube-feb4bdfd9b46e87aadfa7c0d5338cde887d1f58c.zip
First version with PostgreSQL
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 {