aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0005-email-pod.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrations/0005-email-pod.js')
-rw-r--r--server/initializers/migrations/0005-email-pod.js35
1 files changed, 28 insertions, 7 deletions
diff --git a/server/initializers/migrations/0005-email-pod.js b/server/initializers/migrations/0005-email-pod.js
index d90b674a1..9bbb354bf 100644
--- a/server/initializers/migrations/0005-email-pod.js
+++ b/server/initializers/migrations/0005-email-pod.js
@@ -1,18 +1,39 @@
1/* 1'use strict'
2 This is just an example.
3*/
4 2
5// utils = { transaction, queryInterface } 3const waterfall = require('async/waterfall')
6exports.up = function (utils, callback) { 4
5// utils = { transaction, queryInterface, sequelize, Sequelize }
6exports.up = function (utils, finalCallback) {
7 const q = utils.queryInterface 7 const q = utils.queryInterface
8 const Sequelize = utils.Sequelize 8 const Sequelize = utils.Sequelize
9 9
10 const data = { 10 const data = {
11 type: Sequelize.STRING(400), 11 type: Sequelize.STRING(400),
12 allowNull: false 12 allowNull: false,
13 defaultValue: ''
13 } 14 }
14 15
15 q.addColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(callback) 16 waterfall([
17
18 function addEmailColumn (callback) {
19 q.addColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(function (err) {
20 return callback(err)
21 })
22 },
23
24 function updateWithFakeEmails (callback) {
25 const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\''
26 utils.sequelize.query(query, { transaction: utils.transaction }).asCallback(function (err) {
27 return callback(err)
28 })
29 },
30
31 function nullOnDefault (callback) {
32 data.defaultValue = null
33
34 q.changeColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(callback)
35 }
36 ], finalCallback)
16} 37}
17 38
18exports.down = function (options, callback) { 39exports.down = function (options, callback) {