]>
Commit | Line | Data |
---|---|---|
09209296 C |
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 | ||
9 | { | |
10 | const query = ` | |
11 | CREATE TABLE IF NOT EXISTS "videoStreamingPlaylist" | |
12 | ( | |
13 | "id" SERIAL, | |
14 | "type" INTEGER NOT NULL, | |
15 | "playlistUrl" VARCHAR(2000) NOT NULL, | |
16 | "p2pMediaLoaderInfohashes" VARCHAR(255)[] NOT NULL, | |
17 | "segmentsSha256Url" VARCHAR(255) NOT NULL, | |
18 | "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE 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 | await utils.sequelize.query(query) | |
24 | } | |
25 | ||
26 | { | |
27 | const data = { | |
28 | type: Sequelize.INTEGER, | |
29 | allowNull: true, | |
30 | defaultValue: null | |
31 | } | |
32 | ||
33 | await utils.queryInterface.changeColumn('videoRedundancy', 'videoFileId', data) | |
34 | } | |
35 | ||
36 | { | |
37 | const query = 'ALTER TABLE "videoRedundancy" ADD COLUMN "videoStreamingPlaylistId" INTEGER NULL ' + | |
38 | 'REFERENCES "videoStreamingPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE' | |
39 | ||
40 | await utils.sequelize.query(query) | |
41 | } | |
42 | } | |
43 | ||
44 | function down (options) { | |
45 | throw new Error('Not implemented.') | |
46 | } | |
47 | ||
48 | export { | |
49 | up, | |
50 | down | |
51 | } |