]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/migrations/0660-object-storage.ts
53cb89ce67753ac5caf9071881a13f329ede5f10
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0660-object-storage.ts
1 import * as Sequelize from 'sequelize'
2 import { VideoStorage } from '@shared/models'
3
4 async function up (utils: {
5 transaction: Sequelize.Transaction
6 queryInterface: Sequelize.QueryInterface
7 sequelize: Sequelize.Sequelize
8 db: any
9 }): Promise<void> {
10 {
11 const query = `
12 CREATE TABLE IF NOT EXISTS "videoJobInfo" (
13 "id" serial,
14 "pendingMove" INTEGER NOT NULL,
15 "pendingTranscode" INTEGER NOT NULL,
16 "videoId" serial UNIQUE NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
17 "createdAt" timestamp WITH time zone NOT NULL,
18 "updatedAt" timestamp WITH time zone NOT NULL,
19 PRIMARY KEY ("id")
20 );
21 `
22
23 await utils.sequelize.query(query)
24 }
25
26 {
27 await utils.queryInterface.addColumn('videoFile', 'storage', {
28 type: Sequelize.INTEGER,
29 allowNull: true,
30 defaultValue: VideoStorage.FILE_SYSTEM
31 })
32 await utils.queryInterface.changeColumn('videoFile', 'storage', { type: Sequelize.INTEGER, allowNull: false, defaultValue: null })
33 }
34
35 {
36 await utils.queryInterface.addColumn('videoStreamingPlaylist', 'storage', {
37 type: Sequelize.INTEGER,
38 allowNull: true,
39 defaultValue: VideoStorage.FILE_SYSTEM
40 })
41 await utils.queryInterface.changeColumn('videoStreamingPlaylist', 'storage', {
42 type: Sequelize.INTEGER,
43 allowNull: false,
44 defaultValue: null
45 })
46 }
47 }
48
49 function down (options) {
50 throw new Error('Not implemented.')
51 }
52
53 export {
54 up,
55 down
56 }