diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 13:26:25 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-07-05 14:14:16 +0200 |
commit | 6fcd19ba737f1f5614a56c6925adb882dea43b8d (patch) | |
tree | 3365a96d82bc7f00ae504a568725c8e914150cf8 /server/initializers/migrations/0040-video-nsfw.ts | |
parent | 5fe7e898316e18369c3e1aba307b55077adc7bfb (diff) | |
download | PeerTube-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/0040-video-nsfw.ts')
-rw-r--r-- | server/initializers/migrations/0040-video-nsfw.ts | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/server/initializers/migrations/0040-video-nsfw.ts b/server/initializers/migrations/0040-video-nsfw.ts index c61f496f1..046876b61 100644 --- a/server/initializers/migrations/0040-video-nsfw.ts +++ b/server/initializers/migrations/0040-video-nsfw.ts | |||
@@ -1,9 +1,12 @@ | |||
1 | import { waterfall } from 'async' | 1 | import * as Sequelize from 'sequelize' |
2 | 2 | import * as Promise from 'bluebird' | |
3 | // utils = { transaction, queryInterface, sequelize, Sequelize } | 3 | |
4 | function up (utils, finalCallback) { | 4 | function 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.BOOLEAN, | 12 | type: Sequelize.BOOLEAN, |
@@ -11,20 +14,12 @@ function up (utils, finalCallback) { | |||
11 | defaultValue: false | 14 | defaultValue: false |
12 | } | 15 | } |
13 | 16 | ||
14 | waterfall([ | 17 | return q.addColumn('Videos', 'nsfw', data) |
15 | 18 | .then(() => { | |
16 | function addNSFWColumn (callback) { | ||
17 | q.addColumn('Videos', 'nsfw', data, { transaction: utils.transaction }).asCallback(function (err) { | ||
18 | return callback(err) | ||
19 | }) | ||
20 | }, | ||
21 | |||
22 | function nullOnDefault (callback) { | ||
23 | data.defaultValue = null | 19 | data.defaultValue = null |
24 | 20 | ||
25 | q.changeColumn('Videos', 'nsfw', data, { transaction: utils.transaction }).asCallback(callback) | 21 | return q.changeColumn('Videos', 'nsfw', data) |
26 | } | 22 | }) |
27 | ], finalCallback) | ||
28 | } | 23 | } |
29 | 24 | ||
30 | function down (options, callback) { | 25 | function down (options, callback) { |