From 4793c343fd3cde3c6282ed0fb38e039b4276de0e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Feb 2017 19:19:56 +0100 Subject: Add email to pods --- server/initializers/checker.js | 3 ++- server/initializers/constants.js | 5 ++++- server/initializers/migrations/0005-email-pod.js | 20 ++++++++++++++++++++ server/initializers/migrations/0005-example.js | 14 -------------- server/initializers/migrator.js | 9 +++++++-- 5 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 server/initializers/migrations/0005-email-pod.js delete mode 100644 server/initializers/migrations/0005-example.js (limited to 'server/initializers') diff --git a/server/initializers/checker.js b/server/initializers/checker.js index 6471bb4f1..7adbbb37a 100644 --- a/server/initializers/checker.js +++ b/server/initializers/checker.js @@ -28,7 +28,8 @@ function checkMissedConfig () { const required = [ 'listen.port', 'webserver.https', 'webserver.hostname', 'webserver.port', 'database.hostname', 'database.port', 'database.suffix', 'database.username', 'database.password', - 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews' + 'storage.certs', 'storage.videos', 'storage.logs', 'storage.thumbnails', 'storage.previews', + 'admin.email' ] const miss = [] diff --git a/server/initializers/constants.js b/server/initializers/constants.js index ad7cf4f4d..eb0509efe 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js @@ -54,6 +54,9 @@ const CONFIG = { WS: config.get('webserver.https') === true ? 'wss' : 'ws', HOSTNAME: config.get('webserver.hostname'), PORT: config.get('webserver.port') + }, + ADMIN: { + EMAIL: config.get('admin.email') } } CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT @@ -92,7 +95,7 @@ const FRIEND_SCORE = { // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 0 +const LAST_MIGRATION_VERSION = 5 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0005-email-pod.js b/server/initializers/migrations/0005-email-pod.js new file mode 100644 index 000000000..d90b674a1 --- /dev/null +++ b/server/initializers/migrations/0005-email-pod.js @@ -0,0 +1,20 @@ +/* + This is just an example. +*/ + +// utils = { transaction, queryInterface } +exports.up = function (utils, callback) { + const q = utils.queryInterface + const Sequelize = utils.Sequelize + + const data = { + type: Sequelize.STRING(400), + allowNull: false + } + + q.addColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(callback) +} + +exports.down = function (options, callback) { + throw new Error('Not implemented.') +} diff --git a/server/initializers/migrations/0005-example.js b/server/initializers/migrations/0005-example.js deleted file mode 100644 index cedc42919..000000000 --- a/server/initializers/migrations/0005-example.js +++ /dev/null @@ -1,14 +0,0 @@ -// /* -// This is just an example. -// */ - -// const db = require('../database') - -// // options contains the transaction -// exports.up = function (options, callback) { -// db.Application.create({ migrationVersion: 42 }, { transaction: options.transaction }).asCallback(callback) -// } - -// exports.down = function (options, callback) { -// throw new Error('Not implemented.') -// } diff --git a/server/initializers/migrator.js b/server/initializers/migrator.js index e5288b615..233ee2bdd 100644 --- a/server/initializers/migrator.js +++ b/server/initializers/migrator.js @@ -64,7 +64,7 @@ function getMigrationScripts (callback) { } function executeMigration (actualVersion, entity, callback) { - const versionScript = entity.version + const versionScript = parseInt(entity.version) // Do not execute old migration scripts if (versionScript <= actualVersion) return callback(null) @@ -78,7 +78,12 @@ function executeMigration (actualVersion, entity, callback) { db.sequelize.transaction().asCallback(function (err, t) { if (err) return callback(err) - migrationScript.up({ transaction: t }, function (err) { + const options = { + transaction: t, + queryInterface: db.sequelize.getQueryInterface(), + Sequelize: db.Sequelize + } + migrationScript.up(options, function (err) { if (err) { t.rollback() return callback(err) -- cgit v1.2.3