]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/migrations/0005-email-pod.ts
Try to fix video duplication
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0005-email-pod.ts
1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
3 import { Migration } from '../../models/migrations'
4
5 function up (utils: {
6 transaction: Sequelize.Transaction,
7 queryInterface: Sequelize.QueryInterface,
8 sequelize: Sequelize.Sequelize
9 }): Promise<void> {
10 const q = utils.queryInterface
11
12 const data = {
13 type: Sequelize.STRING(400),
14 allowNull: false,
15 defaultValue: ''
16 } as Migration.String
17
18 return q.addColumn('Pods', 'email', data)
19 .then(() => {
20 const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\''
21 return utils.sequelize.query(query, { transaction: utils.transaction })
22 })
23 .then(() => {
24 data.defaultValue = null
25
26 return q.changeColumn('Pods', 'email', data)
27 })
28 }
29
30 function down (options) {
31 throw new Error('Not implemented.')
32 }
33
34 export {
35 up,
36 down
37 }