aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0005-email-pod.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-05-15 22:22:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-05-20 09:57:40 +0200
commit65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch)
tree4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/initializers/migrations/0005-email-pod.ts
parentd5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff)
downloadPeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst
PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip
First typescript iteration
Diffstat (limited to 'server/initializers/migrations/0005-email-pod.ts')
-rw-r--r--server/initializers/migrations/0005-email-pod.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/server/initializers/migrations/0005-email-pod.ts b/server/initializers/migrations/0005-email-pod.ts
new file mode 100644
index 000000000..a9200c47f
--- /dev/null
+++ b/server/initializers/migrations/0005-email-pod.ts
@@ -0,0 +1,44 @@
1import { waterfall } from 'async'
2
3// utils = { transaction, queryInterface, sequelize, Sequelize }
4function up (utils, finalCallback) {
5 const q = utils.queryInterface
6 const Sequelize = utils.Sequelize
7
8 const data = {
9 type: Sequelize.STRING(400),
10 allowNull: false,
11 defaultValue: ''
12 }
13
14 waterfall([
15
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\''
24 utils.sequelize.query(query, { transaction: utils.transaction }).asCallback(function (err) {
25 return callback(err)
26 })
27 },
28
29 function nullOnDefault (callback) {
30 data.defaultValue = null
31
32 q.changeColumn('Pods', 'email', data, { transaction: utils.transaction }).asCallback(callback)
33 }
34 ], finalCallback)
35}
36
37function down (options, callback) {
38 throw new Error('Not implemented.')
39}
40
41export {
42 up,
43 down
44}