]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/migrations/0010-email-user.ts
Remove octet stream fallback for video extension
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0010-email-user.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 return q.addColumn('Users', 'email', data)
18 .then(() => {
19 const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')'
20 return utils.sequelize.query(query, { transaction: utils.transaction })
21 })
22 .then(() => {
23 data.defaultValue = null
24
25 return q.changeColumn('Users', 'email', data)
26 })
27 }
28
29 function down (options) {
30 throw new Error('Not implemented.')
31 }
32
33 export {
34 up,
35 down
36 }