aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0010-email-user.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-07-05 13:26:25 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-07-05 14:14:16 +0200
commit6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch)
tree3365a96d82bc7f00ae504a568725c8e914150cf8 /server/initializers/migrations/0010-email-user.ts
parent5fe7e898316e18369c3e1aba307b55077adc7bfb (diff)
downloadPeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.gz
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.tar.zst
PeerTube-6fcd19ba737f1f5614a56c6925adb882dea43b8d.zip
Move to promises
Closes https://github.com/Chocobozzz/PeerTube/issues/74
Diffstat (limited to 'server/initializers/migrations/0010-email-user.ts')
-rw-r--r--server/initializers/migrations/0010-email-user.ts39
1 files changed, 15 insertions, 24 deletions
diff --git a/server/initializers/migrations/0010-email-user.ts b/server/initializers/migrations/0010-email-user.ts
index 4b5d29394..e8865acdb 100644
--- a/server/initializers/migrations/0010-email-user.ts
+++ b/server/initializers/migrations/0010-email-user.ts
@@ -1,37 +1,28 @@
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),
10 allowNull: false, 13 allowNull: false,
11 defaultValue: '' 14 defaultValue: ''
12 } 15 }
13 16 return q.addColumn('Users', 'email', data)
14 waterfall([ 17 .then(() => {
15
16 function addEmailColumn (callback) {
17 q.addColumn('Users', 'email', data, { transaction: utils.transaction }).asCallback(function (err) {
18 return callback(err)
19 })
20 },
21
22 function updateWithFakeEmails (callback) {
23 const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')' 18 const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')'
24 utils.sequelize.query(query, { transaction: utils.transaction }).asCallback(function (err) { 19 return utils.sequelize.query(query, { transaction: utils.transaction })
25 return callback(err) 20 })
26 }) 21 .then(() => {
27 },
28
29 function nullOnDefault (callback) {
30 data.defaultValue = null 22 data.defaultValue = null
31 23
32 q.changeColumn('Users', 'email', data, { transaction: utils.transaction }).asCallback(callback) 24 return q.changeColumn('Users', 'email', data)
33 } 25 })
34 ], finalCallback)
35} 26}
36 27
37function down (options, callback) { 28function down (options, callback) {