aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0005-email-pod.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrations/0005-email-pod.ts')
-rw-r--r--server/initializers/migrations/0005-email-pod.ts38
1 files changed, 15 insertions, 23 deletions
diff --git a/server/initializers/migrations/0005-email-pod.ts b/server/initializers/migrations/0005-email-pod.ts
index a9200c47f..ceefaad4a 100644
--- a/server/initializers/migrations/0005-email-pod.ts
+++ b/server/initializers/migrations/0005-email-pod.ts
@@ -1,9 +1,12 @@
1import { waterfall } from 'async' 1import * as Sequelize from 'sequelize'
2 2import * as Promise from 'bluebird'
3// utils = { transaction, queryInterface, sequelize, Sequelize } 3
4function up (utils, finalCallback) { 4function up (utils: {
5 transaction: Sequelize.Transaction,
6 queryInterface: Sequelize.QueryInterface,
7 sequelize: Sequelize.Sequelize
8}): Promise<void> {
5 const q = utils.queryInterface 9 const q = utils.queryInterface
6 const Sequelize = utils.Sequelize
7 10
8 const data = { 11 const data = {
9 type: Sequelize.STRING(400), 12 type: Sequelize.STRING(400),
@@ -11,27 +14,16 @@ function up (utils, finalCallback) {
11 defaultValue: '' 14 defaultValue: ''
12 } 15 }
13 16
14 waterfall([ 17 return q.addColumn('Pods', 'email', data)
15 18 .then(() => {
16 function addEmailColumn (callback) {
17 q.addColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(function (err) {
18 return callback(err)
19 })
20 },
21
22 function updateWithFakeEmails (callback) {
23 const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\'' 19 const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\''
24 utils.sequelize.query(query, { transaction: utils.transaction }).asCallback(function (err) { 20 return utils.sequelize.query(query, { transaction: utils.transaction })
25 return callback(err) 21 })
26 }) 22 .then(() => {
27 },
28
29 function nullOnDefault (callback) {
30 data.defaultValue = null 23 data.defaultValue = null
31 24
32 q.changeColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(callback) 25 return q.changeColumn('Pods', 'email', data)
33 } 26 })
34 ], finalCallback)
35} 27}
36 28
37function down (options, callback) { 29function down (options, callback) {