aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r--server/initializers/migrations/0370-thumbnail.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/server/initializers/migrations/0370-thumbnail.ts b/server/initializers/migrations/0370-thumbnail.ts
new file mode 100644
index 000000000..384ca1a15
--- /dev/null
+++ b/server/initializers/migrations/0370-thumbnail.ts
@@ -0,0 +1,50 @@
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 {
10 const query = `
11CREATE TABLE IF NOT EXISTS "thumbnail"
12(
13 "id" SERIAL,
14 "filename" VARCHAR(255) NOT NULL,
15 "height" INTEGER DEFAULT NULL,
16 "width" INTEGER DEFAULT NULL,
17 "type" INTEGER NOT NULL,
18 "fileUrl" VARCHAR(255),
19 "videoId" INTEGER REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
20 "videoPlaylistId" INTEGER REFERENCES "videoPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
21 "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
22 "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
23 PRIMARY KEY ("id")
24);`
25 await utils.sequelize.query(query)
26 }
27
28 {
29 // All video thumbnails
30 const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' +
31 'SELECT uuid || \'.jpg\', 1, id, 110, 200, NOW(), NOW() FROM "video"'
32 await utils.sequelize.query(query)
33 }
34
35 {
36 // All video previews
37 const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' +
38 'SELECT uuid || \'.jpg\', 2, id, 315, 560, NOW(), NOW() FROM "video"'
39 await utils.sequelize.query(query)
40 }
41}
42
43function down (options) {
44 throw new Error('Not implemented.')
45}
46
47export {
48 up,
49 down
50}