aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0705-local-video-viewers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrations/0705-local-video-viewers.ts')
-rw-r--r--server/initializers/migrations/0705-local-video-viewers.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/server/initializers/migrations/0705-local-video-viewers.ts b/server/initializers/migrations/0705-local-video-viewers.ts
new file mode 100644
index 000000000..123402641
--- /dev/null
+++ b/server/initializers/migrations/0705-local-video-viewers.ts
@@ -0,0 +1,52 @@
1import * as Sequelize from 'sequelize'
2
3async 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 {
12 const query = `
13 CREATE TABLE IF NOT EXISTS "localVideoViewer" (
14 "id" serial,
15 "startDate" timestamp with time zone NOT NULL,
16 "endDate" timestamp with time zone NOT NULL,
17 "watchTime" integer NOT NULL,
18 "country" varchar(255),
19 "uuid" uuid NOT NULL,
20 "url" varchar(255) NOT NULL,
21 "videoId" integer NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
22 "createdAt" timestamp with time zone NOT NULL,
23 PRIMARY KEY ("id")
24 );
25 `
26 await utils.sequelize.query(query, { transaction })
27 }
28
29 {
30 const query = `
31 CREATE TABLE IF NOT EXISTS "localVideoViewerWatchSection" (
32 "id" serial,
33 "watchStart" integer NOT NULL,
34 "watchEnd" integer NOT NULL,
35 "localVideoViewerId" integer NOT NULL REFERENCES "localVideoViewer" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
36 "createdAt" timestamp with time zone NOT NULL,
37 PRIMARY KEY ("id")
38 );
39 `
40 await utils.sequelize.query(query, { transaction })
41 }
42
43}
44
45function down () {
46 throw new Error('Not implemented.')
47}
48
49export {
50 up,
51 down
52}