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/0530-playlist-multiple-video.ts46
2 files changed, 47 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 2f9a750a5..c26c3a88c 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -23,7 +23,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
23 23
24// --------------------------------------------------------------------------- 24// ---------------------------------------------------------------------------
25 25
26const LAST_MIGRATION_VERSION = 525 26const LAST_MIGRATION_VERSION = 530
27 27
28// --------------------------------------------------------------------------- 28// ---------------------------------------------------------------------------
29 29
diff --git a/server/initializers/migrations/0530-playlist-multiple-video.ts b/server/initializers/migrations/0530-playlist-multiple-video.ts
new file mode 100644
index 000000000..51a8c06b0
--- /dev/null
+++ b/server/initializers/migrations/0530-playlist-multiple-video.ts
@@ -0,0 +1,46 @@
1import * as Sequelize from 'sequelize'
2import { WEBSERVER } from '../constants'
3
4async function up (utils: {
5 transaction: Sequelize.Transaction
6 queryInterface: Sequelize.QueryInterface
7 sequelize: Sequelize.Sequelize
8}): Promise<void> {
9 {
10 const field = {
11 type: Sequelize.STRING,
12 allowNull: true
13 }
14 await utils.queryInterface.changeColumn('videoPlaylistElement', 'url', field)
15 }
16
17 {
18 await utils.sequelize.query('DROP INDEX IF EXISTS video_playlist_element_video_playlist_id_video_id;')
19 }
20
21 {
22 const selectPlaylistUUID = 'SELECT "uuid" FROM "videoPlaylist" WHERE "id" = "videoPlaylistElement"."videoPlaylistId"'
23 const url = `'${WEBSERVER.URL}' || '/video-playlists/' || (${selectPlaylistUUID}) || '/videos/' || "videoPlaylistElement"."id"`
24
25 const query = `
26 UPDATE "videoPlaylistElement" SET "url" = ${url} WHERE id IN (
27 SELECT "videoPlaylistElement"."id" FROM "videoPlaylistElement"
28 INNER JOIN "videoPlaylist" ON "videoPlaylist".id = "videoPlaylistElement"."videoPlaylistId"
29 INNER JOIN account ON account.id = "videoPlaylist"."ownerAccountId"
30 INNER JOIN actor ON actor.id = account."actorId"
31 WHERE actor."serverId" IS NULL
32 )`
33
34 await utils.sequelize.query(query)
35 }
36
37}
38
39function down (options) {
40 throw new Error('Not implemented.')
41}
42
43export {
44 up,
45 down
46}