aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0580-caption-filename.ts48
2 files changed, 49 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index a9f7a8e58..be5db8fe8 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
24 24
25// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
26 26
27const LAST_MIGRATION_VERSION = 575 27const LAST_MIGRATION_VERSION = 580
28 28
29// --------------------------------------------------------------------------- 29// ---------------------------------------------------------------------------
30 30
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}