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