aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0710-live-sessions.ts
blob: aaac8d9ce46bebad3e69b0fd84300a9204a3d1e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as Sequelize from 'sequelize'

async function up (utils: {
  transaction: Sequelize.Transaction
  queryInterface: Sequelize.QueryInterface
  sequelize: Sequelize.Sequelize
  db: any
}): Promise<void> {
  const { transaction } = utils

  const query = `
  CREATE TABLE IF NOT EXISTS "videoLiveSession" (
    "id" serial,
    "startDate" timestamp with time zone NOT NULL,
    "endDate" timestamp with time zone,
    "error" integer,
    "replayVideoId" integer REFERENCES "video" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
    "liveVideoId" integer REFERENCES "video" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
    "createdAt" timestamp with time zone NOT NULL,
    "updatedAt" timestamp with time zone NOT NULL,
    PRIMARY KEY ("id")
  );
  `
  await utils.sequelize.query(query, { transaction })
}

function down () {
  throw new Error('Not implemented.')
}

export {
  up,
  down
}