]>
Commit | Line | Data |
---|---|---|
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 | 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 | ||
41 | function down (options) { | |
42 | throw new Error('Not implemented.') | |
43 | } | |
44 | ||
45 | export { | |
46 | up, | |
47 | down | |
48 | } |