]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/initializers/migrations/0710-live-sessions.ts
Support live session in server
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0710-live-sessions.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 db: any
8 }): Promise<void> {
9 const { transaction } = utils
10
11 const query = `
12 CREATE TABLE IF NOT EXISTS "videoLiveSession" (
13 "id" serial,
14 "startDate" timestamp with time zone NOT NULL,
15 "endDate" timestamp with time zone,
16 "error" integer,
17 "replayVideoId" integer REFERENCES "video" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
18 "liveVideoId" integer REFERENCES "video" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
19 "createdAt" timestamp with time zone NOT NULL,
20 "updatedAt" timestamp with time zone NOT NULL,
21 PRIMARY KEY ("id")
22 );
23 `
24 await utils.sequelize.query(query, { transaction })
25 }
26
27 function down () {
28 throw new Error('Not implemented.')
29 }
30
31 export {
32 up,
33 down
34 }