aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r--server/initializers/migrations/0580-caption-filename.ts48
1 files changed, 48 insertions, 0 deletions
diff --git a/server/initializers/migrations/0580-caption-filename.ts b/server/initializers/migrations/0580-caption-filename.ts
new file mode 100644
index 000000000..5281fd0c0
--- /dev/null
+++ b/server/initializers/migrations/0580-caption-filename.ts
@@ -0,0 +1,48 @@
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 data = {
11 type: Sequelize.STRING,
12 allowNull: true,
13 defaultValue: null
14 }
15
16 await utils.queryInterface.addColumn('videoCaption', 'filename', data)
17 }
18
19 {
20 const query = `UPDATE "videoCaption" SET "filename" = s.uuid || '-' || s.language || '.vtt' ` +
21 `FROM (` +
22 ` SELECT "videoCaption"."id", video.uuid, "videoCaption".language ` +
23 ` FROM "videoCaption" INNER JOIN video ON video.id = "videoCaption"."videoId"` +
24 `) AS s ` +
25 `WHERE "videoCaption".id = s.id`
26
27 await utils.sequelize.query(query)
28 }
29
30 {
31 const data = {
32 type: Sequelize.STRING,
33 allowNull: false,
34 defaultValue: null
35 }
36
37 await utils.queryInterface.changeColumn('videoCaption', 'filename', data)
38 }
39}
40
41function down (options) {
42 throw new Error('Not implemented.')
43}
44
45export {
46 up,
47 down
48}