]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/migrations/0220-video-state.ts
Try to fix video duplication
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0220-video-state.ts
1 import * as Sequelize from 'sequelize'
2
3 async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7 }): Promise<void> {
8 // waitingTranscoding column
9 {
10 const data = {
11 type: Sequelize.BOOLEAN,
12 allowNull: true,
13 defaultValue: null
14 }
15 await utils.queryInterface.addColumn('video', 'waitTranscoding', data)
16 }
17
18 {
19 const query = 'UPDATE video SET "waitTranscoding" = false'
20 await utils.sequelize.query(query)
21 }
22
23 {
24 const data = {
25 type: Sequelize.BOOLEAN,
26 allowNull: false,
27 defaultValue: null
28 }
29 await utils.queryInterface.changeColumn('video', 'waitTranscoding', data)
30 }
31
32 // state
33 {
34 const data = {
35 type: Sequelize.INTEGER,
36 allowNull: true,
37 defaultValue: null
38 }
39 await utils.queryInterface.addColumn('video', 'state', data)
40 }
41
42 {
43 // Published
44 const query = 'UPDATE video SET "state" = 1'
45 await utils.sequelize.query(query)
46 }
47
48 {
49 const data = {
50 type: Sequelize.INTEGER,
51 allowNull: false,
52 defaultValue: null
53 }
54 await utils.queryInterface.changeColumn('video', 'state', data)
55 }
56 }
57
58 function down (options) {
59 throw new Error('Not implemented.')
60 }
61
62 export { up, down }