Fix federation of some videos
[oweals/peertube.git] / server / initializers / migrations / 0040-video-nsfw.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.BOOLEAN,
14     allowNull: false,
15     defaultValue: false
16   } as Migration.Boolean
17
18   return q.addColumn('Videos', 'nsfw', data)
19     .then(() => {
20       data.defaultValue = null
21
22       return q.changeColumn('Videos', 'nsfw', data)
23     })
24 }
25
26 function down (options) {
27   throw new Error('Not implemented.')
28 }
29
30 export {
31   up,
32   down
33 }