diff options
Diffstat (limited to 'server/initializers/migrations')
61 files changed, 0 insertions, 2500 deletions
diff --git a/server/initializers/migrations/0505-user-last-login-date.ts b/server/initializers/migrations/0505-user-last-login-date.ts deleted file mode 100644 index 29d970802..000000000 --- a/server/initializers/migrations/0505-user-last-login-date.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | |||
9 | { | ||
10 | const field = { | ||
11 | type: Sequelize.DATE, | ||
12 | allowNull: true | ||
13 | } | ||
14 | await utils.queryInterface.addColumn('user', 'lastLoginDate', field) | ||
15 | } | ||
16 | |||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||
diff --git a/server/initializers/migrations/0510-video-file-metadata.ts b/server/initializers/migrations/0510-video-file-metadata.ts deleted file mode 100644 index be9feb47a..000000000 --- a/server/initializers/migrations/0510-video-file-metadata.ts +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | |||
9 | // We made a mistake with the migration in 2.2.0-rc.1 | ||
10 | // Docker containers did not include this migration file | ||
11 | // So we check the table definition and add the column if it does not exist | ||
12 | const tableDefinition = await utils.queryInterface.describeTable('videoFile') | ||
13 | |||
14 | if (!tableDefinition['metadata']) { | ||
15 | const metadata = { | ||
16 | type: Sequelize.JSONB, | ||
17 | allowNull: true | ||
18 | } | ||
19 | await utils.queryInterface.addColumn('videoFile', 'metadata', metadata) | ||
20 | } | ||
21 | |||
22 | if (!tableDefinition['metadataUrl']) { | ||
23 | const metadataUrl = { | ||
24 | type: Sequelize.STRING, | ||
25 | allowNull: true | ||
26 | } | ||
27 | await utils.queryInterface.addColumn('videoFile', 'metadataUrl', metadataUrl) | ||
28 | } | ||
29 | } | ||
30 | |||
31 | function down (options) { | ||
32 | throw new Error('Not implemented.') | ||
33 | } | ||
34 | |||
35 | export { | ||
36 | up, | ||
37 | down | ||
38 | } | ||
diff --git a/server/initializers/migrations/0515-video-abuse-reason-timestamps.ts b/server/initializers/migrations/0515-video-abuse-reason-timestamps.ts deleted file mode 100644 index c58335617..000000000 --- a/server/initializers/migrations/0515-video-abuse-reason-timestamps.ts +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | await utils.queryInterface.addColumn('videoAbuse', 'predefinedReasons', { | ||
9 | type: Sequelize.ARRAY(Sequelize.INTEGER), | ||
10 | allowNull: true | ||
11 | }) | ||
12 | |||
13 | await utils.queryInterface.addColumn('videoAbuse', 'startAt', { | ||
14 | type: Sequelize.INTEGER, | ||
15 | allowNull: true | ||
16 | }) | ||
17 | |||
18 | await utils.queryInterface.addColumn('videoAbuse', 'endAt', { | ||
19 | type: Sequelize.INTEGER, | ||
20 | allowNull: true | ||
21 | }) | ||
22 | } | ||
23 | |||
24 | function down (options) { | ||
25 | throw new Error('Not implemented.') | ||
26 | } | ||
27 | |||
28 | export { | ||
29 | up, | ||
30 | down | ||
31 | } | ||
diff --git a/server/initializers/migrations/0520-abuses-split.ts b/server/initializers/migrations/0520-abuses-split.ts deleted file mode 100644 index 136d5c2b2..000000000 --- a/server/initializers/migrations/0520-abuses-split.ts +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | await utils.queryInterface.renameTable('videoAbuse', 'abuse') | ||
9 | |||
10 | await utils.sequelize.query(` | ||
11 | ALTER TABLE "abuse" | ||
12 | ADD COLUMN "flaggedAccountId" INTEGER REFERENCES "account" ("id") ON DELETE SET NULL ON UPDATE CASCADE | ||
13 | `) | ||
14 | |||
15 | await utils.sequelize.query(` | ||
16 | UPDATE "abuse" SET "videoId" = NULL | ||
17 | WHERE "videoId" NOT IN (SELECT "id" FROM "video") | ||
18 | `) | ||
19 | |||
20 | await utils.sequelize.query(` | ||
21 | UPDATE "abuse" SET "flaggedAccountId" = "videoChannel"."accountId" | ||
22 | FROM "video" INNER JOIN "videoChannel" ON "video"."channelId" = "videoChannel"."id" | ||
23 | WHERE "abuse"."videoId" = "video"."id" | ||
24 | `) | ||
25 | |||
26 | await utils.sequelize.query('DROP INDEX IF EXISTS video_abuse_video_id;') | ||
27 | await utils.sequelize.query('DROP INDEX IF EXISTS video_abuse_reporter_account_id;') | ||
28 | |||
29 | await utils.sequelize.query(` | ||
30 | CREATE TABLE IF NOT EXISTS "videoAbuse" ( | ||
31 | "id" serial, | ||
32 | "startAt" integer DEFAULT NULL, | ||
33 | "endAt" integer DEFAULT NULL, | ||
34 | "deletedVideo" jsonb DEFAULT NULL, | ||
35 | "abuseId" integer NOT NULL REFERENCES "abuse" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
36 | "videoId" integer REFERENCES "video" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
37 | "createdAt" TIMESTAMP WITH time zone NOT NULL, | ||
38 | "updatedAt" timestamp WITH time zone NOT NULL, | ||
39 | PRIMARY KEY ("id") | ||
40 | ); | ||
41 | `) | ||
42 | |||
43 | await utils.sequelize.query(` | ||
44 | CREATE TABLE IF NOT EXISTS "commentAbuse" ( | ||
45 | "id" serial, | ||
46 | "abuseId" integer NOT NULL REFERENCES "abuse" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
47 | "videoCommentId" integer REFERENCES "videoComment" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
48 | "createdAt" timestamp WITH time zone NOT NULL, | ||
49 | "updatedAt" timestamp WITH time zone NOT NULL, | ||
50 | PRIMARY KEY ("id") | ||
51 | ); | ||
52 | `) | ||
53 | |||
54 | await utils.sequelize.query(` | ||
55 | INSERT INTO "videoAbuse" ("startAt", "endAt", "deletedVideo", "abuseId", "videoId", "createdAt", "updatedAt") | ||
56 | SELECT "abuse"."startAt", "abuse"."endAt", "abuse"."deletedVideo", "abuse"."id", "abuse"."videoId", | ||
57 | "abuse"."createdAt", "abuse"."updatedAt" | ||
58 | FROM "abuse" | ||
59 | `) | ||
60 | |||
61 | await utils.queryInterface.removeColumn('abuse', 'startAt') | ||
62 | await utils.queryInterface.removeColumn('abuse', 'endAt') | ||
63 | await utils.queryInterface.removeColumn('abuse', 'deletedVideo') | ||
64 | await utils.queryInterface.removeColumn('abuse', 'videoId') | ||
65 | |||
66 | await utils.sequelize.query('DROP INDEX IF EXISTS user_notification_video_abuse_id') | ||
67 | await utils.queryInterface.renameColumn('userNotification', 'videoAbuseId', 'abuseId') | ||
68 | |||
69 | await utils.sequelize.query( | ||
70 | 'ALTER INDEX IF EXISTS "videoAbuse_pkey" RENAME TO "abuse_pkey"' | ||
71 | ) | ||
72 | |||
73 | await utils.queryInterface.renameColumn('userNotificationSetting', 'videoAbuseAsModerator', 'abuseAsModerator') | ||
74 | } | ||
75 | |||
76 | function down (options) { | ||
77 | throw new Error('Not implemented.') | ||
78 | } | ||
79 | |||
80 | export { | ||
81 | up, | ||
82 | down | ||
83 | } | ||
diff --git a/server/initializers/migrations/0525-abuse-messages.ts b/server/initializers/migrations/0525-abuse-messages.ts deleted file mode 100644 index c8fd7cbcf..000000000 --- a/server/initializers/migrations/0525-abuse-messages.ts +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | await utils.sequelize.query(` | ||
9 | CREATE TABLE IF NOT EXISTS "abuseMessage" ( | ||
10 | "id" serial, | ||
11 | "message" text NOT NULL, | ||
12 | "byModerator" boolean NOT NULL, | ||
13 | "accountId" integer REFERENCES "account" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
14 | "abuseId" integer NOT NULL REFERENCES "abuse" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
15 | "createdAt" timestamp WITH time zone NOT NULL, | ||
16 | "updatedAt" timestamp WITH time zone NOT NULL, | ||
17 | PRIMARY KEY ("id") | ||
18 | ); | ||
19 | `) | ||
20 | |||
21 | const notificationSettingColumns = [ 'abuseStateChange', 'abuseNewMessage' ] | ||
22 | |||
23 | for (const column of notificationSettingColumns) { | ||
24 | const data = { | ||
25 | type: Sequelize.INTEGER, | ||
26 | defaultValue: null, | ||
27 | allowNull: true | ||
28 | } | ||
29 | await utils.queryInterface.addColumn('userNotificationSetting', column, data) | ||
30 | } | ||
31 | |||
32 | { | ||
33 | const query = 'UPDATE "userNotificationSetting" SET "abuseStateChange" = 3, "abuseNewMessage" = 3' | ||
34 | await utils.sequelize.query(query) | ||
35 | } | ||
36 | |||
37 | for (const column of notificationSettingColumns) { | ||
38 | const data = { | ||
39 | type: Sequelize.INTEGER, | ||
40 | defaultValue: null, | ||
41 | allowNull: false | ||
42 | } | ||
43 | await utils.queryInterface.changeColumn('userNotificationSetting', column, data) | ||
44 | } | ||
45 | } | ||
46 | |||
47 | function down (options) { | ||
48 | throw new Error('Not implemented.') | ||
49 | } | ||
50 | |||
51 | export { | ||
52 | up, | ||
53 | down | ||
54 | } | ||
diff --git a/server/initializers/migrations/0530-playlist-multiple-video.ts b/server/initializers/migrations/0530-playlist-multiple-video.ts deleted file mode 100644 index 51a8c06b0..000000000 --- a/server/initializers/migrations/0530-playlist-multiple-video.ts +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { WEBSERVER } from '../constants' | ||
3 | |||
4 | async 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 | |||
39 | function down (options) { | ||
40 | throw new Error('Not implemented.') | ||
41 | } | ||
42 | |||
43 | export { | ||
44 | up, | ||
45 | down | ||
46 | } | ||
diff --git a/server/initializers/migrations/0535-video-live.ts b/server/initializers/migrations/0535-video-live.ts deleted file mode 100644 index 7501e080b..000000000 --- a/server/initializers/migrations/0535-video-live.ts +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | { | ||
9 | const query = ` | ||
10 | CREATE TABLE IF NOT EXISTS "videoLive" ( | ||
11 | "id" SERIAL , | ||
12 | "streamKey" VARCHAR(255), | ||
13 | "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
14 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
15 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
16 | PRIMARY KEY ("id") | ||
17 | ); | ||
18 | ` | ||
19 | |||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | await utils.queryInterface.addColumn('video', 'isLive', { | ||
25 | type: Sequelize.BOOLEAN, | ||
26 | defaultValue: false, | ||
27 | allowNull: false | ||
28 | }) | ||
29 | } | ||
30 | } | ||
31 | |||
32 | function down (options) { | ||
33 | throw new Error('Not implemented.') | ||
34 | } | ||
35 | |||
36 | export { | ||
37 | up, | ||
38 | down | ||
39 | } | ||
diff --git a/server/initializers/migrations/0540-video-file-infohash.ts b/server/initializers/migrations/0540-video-file-infohash.ts deleted file mode 100644 index 550178dab..000000000 --- a/server/initializers/migrations/0540-video-file-infohash.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.STRING, | ||
11 | defaultValue: null, | ||
12 | allowNull: true | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.changeColumn('videoFile', 'infoHash', data) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||
diff --git a/server/initializers/migrations/0545-video-live-save-replay.ts b/server/initializers/migrations/0545-video-live-save-replay.ts deleted file mode 100644 index b79a406a4..000000000 --- a/server/initializers/migrations/0545-video-live-save-replay.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | defaultValue: false, | ||
12 | allowNull: false | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('videoLive', 'saveReplay', data) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||
diff --git a/server/initializers/migrations/0550-actor-follow-cleanup.ts b/server/initializers/migrations/0550-actor-follow-cleanup.ts deleted file mode 100644 index 8ba6feec2..000000000 --- a/server/initializers/migrations/0550-actor-follow-cleanup.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | const query = ` | ||
9 | WITH t AS ( | ||
10 | SELECT actor.id FROM actor | ||
11 | LEFT JOIN "videoChannel" ON "videoChannel"."actorId" = actor.id | ||
12 | LEFT JOIN account ON account."actorId" = "actor"."id" | ||
13 | WHERE "videoChannel".id IS NULL and "account".id IS NULL | ||
14 | ) DELETE FROM "actorFollow" WHERE "actorId" IN (SELECT t.id FROM t) OR "targetActorId" in (SELECT t.id FROM t) | ||
15 | ` | ||
16 | |||
17 | await utils.sequelize.query(query) | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0555-actor-follow-url.ts b/server/initializers/migrations/0555-actor-follow-url.ts deleted file mode 100644 index 36431507f..000000000 --- a/server/initializers/migrations/0555-actor-follow-url.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.STRING(2000), | ||
11 | defaultValue: null, | ||
12 | allowNull: true | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('actorFollow', 'url', data) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||
diff --git a/server/initializers/migrations/0560-user-feed-token.ts b/server/initializers/migrations/0560-user-feed-token.ts deleted file mode 100644 index 4c85b04f7..000000000 --- a/server/initializers/migrations/0560-user-feed-token.ts +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { buildUUID } from '@shared/extra-utils' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | db: any | ||
9 | }): Promise<void> { | ||
10 | const q = utils.queryInterface | ||
11 | |||
12 | { | ||
13 | // Create uuid column for users | ||
14 | const userFeedTokenUUID = { | ||
15 | type: Sequelize.UUID, | ||
16 | defaultValue: Sequelize.UUIDV4, | ||
17 | allowNull: true | ||
18 | } | ||
19 | await q.addColumn('user', 'feedToken', userFeedTokenUUID) | ||
20 | } | ||
21 | |||
22 | // Set UUID to previous users | ||
23 | { | ||
24 | const query = 'SELECT * FROM "user" WHERE "feedToken" IS NULL' | ||
25 | const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT } | ||
26 | const users = await utils.sequelize.query<any>(query, options) | ||
27 | |||
28 | for (const user of users) { | ||
29 | const queryUpdate = `UPDATE "user" SET "feedToken" = '${buildUUID()}' WHERE id = ${user.id}` | ||
30 | await utils.sequelize.query(queryUpdate) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | { | ||
35 | const userFeedTokenUUID = { | ||
36 | type: Sequelize.UUID, | ||
37 | defaultValue: Sequelize.UUIDV4, | ||
38 | allowNull: false | ||
39 | } | ||
40 | await q.changeColumn('user', 'feedToken', userFeedTokenUUID) | ||
41 | } | ||
42 | } | ||
43 | |||
44 | function down (options) { | ||
45 | throw new Error('Not implemented.') | ||
46 | } | ||
47 | |||
48 | export { | ||
49 | up, | ||
50 | down | ||
51 | } | ||
diff --git a/server/initializers/migrations/0565-actor-follow-local-url.ts b/server/initializers/migrations/0565-actor-follow-local-url.ts deleted file mode 100644 index 779a59475..000000000 --- a/server/initializers/migrations/0565-actor-follow-local-url.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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 query = ` | ||
11 | UPDATE "actorFollow" SET url = follower.url || '/follows/' || following.id | ||
12 | FROM actor follower, actor following | ||
13 | WHERE follower."serverId" IS NULL AND follower.id = "actorFollow"."actorId" AND following.id = "actorFollow"."targetActorId" | ||
14 | ` | ||
15 | |||
16 | await utils.sequelize.query(query) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0570-permanent-live.ts b/server/initializers/migrations/0570-permanent-live.ts deleted file mode 100644 index 9572a9b2d..000000000 --- a/server/initializers/migrations/0570-permanent-live.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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.BOOLEAN, | ||
12 | defaultValue: false, | ||
13 | allowNull: false | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('videoLive', 'permanentLive', data) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0575-duplicate-thumbnail.ts b/server/initializers/migrations/0575-duplicate-thumbnail.ts deleted file mode 100644 index 4dbbe71d4..000000000 --- a/server/initializers/migrations/0575-duplicate-thumbnail.ts +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
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 query = 'DELETE FROM "thumbnail" s1 ' + | ||
11 | 'USING (SELECT MIN(id) as id, "filename", "type" FROM "thumbnail" GROUP BY "filename", "type" HAVING COUNT(*) > 1) s2 ' + | ||
12 | 'WHERE s1."filename" = s2."filename" AND s1."type" = s2."type" AND s1.id <> s2.id' | ||
13 | await utils.sequelize.query(query) | ||
14 | } | ||
15 | } | ||
16 | |||
17 | function down (options) { | ||
18 | throw new Error('Not implemented.') | ||
19 | } | ||
20 | |||
21 | export { | ||
22 | up, | ||
23 | down | ||
24 | } | ||
diff --git a/server/initializers/migrations/0580-caption-filename.ts b/server/initializers/migrations/0580-caption-filename.ts deleted file mode 100644 index 5281fd0c0..000000000 --- a/server/initializers/migrations/0580-caption-filename.ts +++ /dev/null | |||
@@ -1,48 +0,0 @@ | |||
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 | } | ||
diff --git a/server/initializers/migrations/0585-video-file-names.ts b/server/initializers/migrations/0585-video-file-names.ts deleted file mode 100644 index dd5fec3a1..000000000 --- a/server/initializers/migrations/0585-video-file-names.ts +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
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 | for (const column of [ 'filename', 'fileUrl', 'torrentFilename', 'torrentUrl' ]) { | ||
10 | const data = { | ||
11 | type: Sequelize.STRING, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('videoFile', column, data) | ||
17 | } | ||
18 | |||
19 | // Generate filenames for webtorrent files | ||
20 | { | ||
21 | const webtorrentQuery = `SELECT "videoFile".id, "video".uuid, "videoFile".resolution, "videoFile".extname ` + | ||
22 | `FROM video INNER JOIN "videoFile" ON "videoFile"."videoId" = video.id` | ||
23 | |||
24 | const query = `UPDATE "videoFile" ` + | ||
25 | `SET filename = t.uuid || '-' || t.resolution || t.extname, ` + | ||
26 | `"torrentFilename" = t.uuid || '-' || t.resolution || '.torrent' ` + | ||
27 | `FROM (${webtorrentQuery}) AS t WHERE t.id = "videoFile"."id"` | ||
28 | |||
29 | await utils.sequelize.query(query) | ||
30 | } | ||
31 | |||
32 | // Generate filenames for HLS files | ||
33 | { | ||
34 | const hlsQuery = `SELECT "videoFile".id, "video".uuid, "videoFile".resolution, "videoFile".extname ` + | ||
35 | `FROM video ` + | ||
36 | `INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."videoId" = video.id ` + | ||
37 | `INNER JOIN "videoFile" ON "videoFile"."videoStreamingPlaylistId" = "videoStreamingPlaylist".id` | ||
38 | |||
39 | const query = `UPDATE "videoFile" ` + | ||
40 | `SET filename = t.uuid || '-' || t.resolution || '-fragmented' || t.extname, ` + | ||
41 | `"torrentFilename" = t.uuid || '-' || t.resolution || '-hls.torrent' ` + | ||
42 | `FROM (${hlsQuery}) AS t WHERE t.id = "videoFile"."id"` | ||
43 | |||
44 | await utils.sequelize.query(query) | ||
45 | } | ||
46 | } | ||
47 | |||
48 | function down (options) { | ||
49 | throw new Error('Not implemented.') | ||
50 | } | ||
51 | |||
52 | export { | ||
53 | up, | ||
54 | down | ||
55 | } | ||
diff --git a/server/initializers/migrations/0590-trackers.ts b/server/initializers/migrations/0590-trackers.ts deleted file mode 100644 index 47b9022a3..000000000 --- a/server/initializers/migrations/0590-trackers.ts +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
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 query = `CREATE TABLE IF NOT EXISTS "tracker" ( | ||
11 | "id" serial, | ||
12 | "url" varchar(255) NOT NULL, | ||
13 | "createdAt" timestamp WITH time zone NOT NULL, | ||
14 | "updatedAt" timestamp WITH time zone NOT NULL, | ||
15 | PRIMARY KEY ("id") | ||
16 | );` | ||
17 | |||
18 | await utils.sequelize.query(query) | ||
19 | } | ||
20 | |||
21 | { | ||
22 | const query = `CREATE TABLE IF NOT EXISTS "videoTracker" ( | ||
23 | "videoId" integer REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
24 | "trackerId" integer REFERENCES "tracker" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
25 | "createdAt" timestamp WITH time zone NOT NULL, | ||
26 | "updatedAt" timestamp WITH time zone NOT NULL, | ||
27 | UNIQUE ("videoId", "trackerId"), | ||
28 | PRIMARY KEY ("videoId", "trackerId") | ||
29 | );` | ||
30 | |||
31 | await utils.sequelize.query(query) | ||
32 | } | ||
33 | |||
34 | await utils.sequelize.query(`CREATE UNIQUE INDEX "tracker_url" ON "tracker" ("url")`) | ||
35 | } | ||
36 | |||
37 | function down (options) { | ||
38 | throw new Error('Not implemented.') | ||
39 | } | ||
40 | |||
41 | export { | ||
42 | up, | ||
43 | down | ||
44 | } | ||
diff --git a/server/initializers/migrations/0595-remote-url.ts b/server/initializers/migrations/0595-remote-url.ts deleted file mode 100644 index 85b367555..000000000 --- a/server/initializers/migrations/0595-remote-url.ts +++ /dev/null | |||
@@ -1,130 +0,0 @@ | |||
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 | // Torrent and file URLs | ||
11 | { | ||
12 | const fromQueryWebtorrent = `SELECT 'https://' || server.host AS "serverUrl", '/static/webseed/' AS "filePath", "videoFile".id ` + | ||
13 | `FROM video ` + | ||
14 | `INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" ` + | ||
15 | `INNER JOIN actor ON actor.id = "videoChannel"."actorId" ` + | ||
16 | `INNER JOIN server ON server.id = actor."serverId" ` + | ||
17 | `INNER JOIN "videoFile" ON "videoFile"."videoId" = video.id ` + | ||
18 | `WHERE video.remote IS TRUE` | ||
19 | |||
20 | const fromQueryHLS = `SELECT 'https://' || server.host AS "serverUrl", ` + | ||
21 | `'/static/streaming-playlists/hls/' || video.uuid || '/' AS "filePath", "videoFile".id ` + | ||
22 | `FROM video ` + | ||
23 | `INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" ` + | ||
24 | `INNER JOIN actor ON actor.id = "videoChannel"."actorId" ` + | ||
25 | `INNER JOIN server ON server.id = actor."serverId" ` + | ||
26 | `INNER JOIN "videoStreamingPlaylist" ON "videoStreamingPlaylist"."videoId" = video.id ` + | ||
27 | `INNER JOIN "videoFile" ON "videoFile"."videoStreamingPlaylistId" = "videoStreamingPlaylist".id ` + | ||
28 | `WHERE video.remote IS TRUE` | ||
29 | |||
30 | for (const fromQuery of [ fromQueryWebtorrent, fromQueryHLS ]) { | ||
31 | const query = `UPDATE "videoFile" ` + | ||
32 | `SET "torrentUrl" = t."serverUrl" || '/static/torrents/' || "videoFile"."torrentFilename", ` + | ||
33 | `"fileUrl" = t."serverUrl" || t."filePath" || "videoFile"."filename" ` + | ||
34 | `FROM (${fromQuery}) AS t WHERE t.id = "videoFile"."id" AND "videoFile"."fileUrl" IS NULL` | ||
35 | |||
36 | await utils.sequelize.query(query) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | // Caption URLs | ||
41 | { | ||
42 | const fromQuery = `SELECT 'https://' || server.host AS "serverUrl", "video".uuid, "videoCaption".id ` + | ||
43 | `FROM video ` + | ||
44 | `INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" ` + | ||
45 | `INNER JOIN actor ON actor.id = "videoChannel"."actorId" ` + | ||
46 | `INNER JOIN server ON server.id = actor."serverId" ` + | ||
47 | `INNER JOIN "videoCaption" ON "videoCaption"."videoId" = video.id ` + | ||
48 | `WHERE video.remote IS TRUE` | ||
49 | |||
50 | const query = `UPDATE "videoCaption" ` + | ||
51 | `SET "fileUrl" = t."serverUrl" || '/lazy-static/video-captions/' || t.uuid || '-' || "videoCaption"."language" || '.vtt' ` + | ||
52 | `FROM (${fromQuery}) AS t WHERE t.id = "videoCaption"."id" AND "videoCaption"."fileUrl" IS NULL` | ||
53 | |||
54 | await utils.sequelize.query(query) | ||
55 | } | ||
56 | |||
57 | // Thumbnail URLs | ||
58 | { | ||
59 | const fromQuery = `SELECT 'https://' || server.host AS "serverUrl", "video".uuid, "thumbnail".id ` + | ||
60 | `FROM video ` + | ||
61 | `INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" ` + | ||
62 | `INNER JOIN actor ON actor.id = "videoChannel"."actorId" ` + | ||
63 | `INNER JOIN server ON server.id = actor."serverId" ` + | ||
64 | `INNER JOIN "thumbnail" ON "thumbnail"."videoId" = video.id ` + | ||
65 | `WHERE video.remote IS TRUE` | ||
66 | |||
67 | // Thumbnails | ||
68 | { | ||
69 | const query = `UPDATE "thumbnail" ` + | ||
70 | `SET "fileUrl" = t."serverUrl" || '/static/thumbnails/' || t.uuid || '.jpg' ` + | ||
71 | `FROM (${fromQuery}) AS t WHERE t.id = "thumbnail"."id" AND "thumbnail"."fileUrl" IS NULL AND thumbnail.type = 1` | ||
72 | |||
73 | await utils.sequelize.query(query) | ||
74 | } | ||
75 | |||
76 | { | ||
77 | // Previews | ||
78 | const query = `UPDATE "thumbnail" ` + | ||
79 | `SET "fileUrl" = t."serverUrl" || '/lazy-static/previews/' || t.uuid || '.jpg' ` + | ||
80 | `FROM (${fromQuery}) AS t WHERE t.id = "thumbnail"."id" AND "thumbnail"."fileUrl" IS NULL AND thumbnail.type = 2` | ||
81 | |||
82 | await utils.sequelize.query(query) | ||
83 | } | ||
84 | } | ||
85 | |||
86 | // Trackers | ||
87 | { | ||
88 | const trackerUrls = [ | ||
89 | `'https://' || server.host || '/tracker/announce'`, | ||
90 | `'wss://' || server.host || '/tracker/socket'` | ||
91 | ] | ||
92 | |||
93 | for (const trackerUrl of trackerUrls) { | ||
94 | { | ||
95 | const query = `INSERT INTO "tracker" ("url", "createdAt", "updatedAt") ` + | ||
96 | `SELECT ${trackerUrl} AS "url", NOW(), NOW() ` + | ||
97 | `FROM video ` + | ||
98 | `INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" ` + | ||
99 | `INNER JOIN actor ON actor.id = "videoChannel"."actorId" ` + | ||
100 | `INNER JOIN server ON server.id = actor."serverId" ` + | ||
101 | `WHERE video.remote IS TRUE ` + | ||
102 | `ON CONFLICT DO NOTHING` | ||
103 | |||
104 | await utils.sequelize.query(query) | ||
105 | } | ||
106 | |||
107 | { | ||
108 | const query = `INSERT INTO "videoTracker" ("videoId", "trackerId", "createdAt", "updatedAt") ` + | ||
109 | `SELECT video.id, (SELECT tracker.id FROM tracker WHERE url = ${trackerUrl}) AS "trackerId", NOW(), NOW()` + | ||
110 | `FROM video ` + | ||
111 | `INNER JOIN "videoChannel" ON "videoChannel".id = video."channelId" ` + | ||
112 | `INNER JOIN actor ON actor.id = "videoChannel"."actorId" ` + | ||
113 | `INNER JOIN server ON server.id = actor."serverId" ` + | ||
114 | `WHERE video.remote IS TRUE` | ||
115 | |||
116 | await utils.sequelize.query(query) | ||
117 | } | ||
118 | } | ||
119 | } | ||
120 | |||
121 | } | ||
122 | |||
123 | function down (options) { | ||
124 | throw new Error('Not implemented.') | ||
125 | } | ||
126 | |||
127 | export { | ||
128 | up, | ||
129 | down | ||
130 | } | ||
diff --git a/server/initializers/migrations/0600-duplicate-video-files.ts b/server/initializers/migrations/0600-duplicate-video-files.ts deleted file mode 100644 index 92d774a79..000000000 --- a/server/initializers/migrations/0600-duplicate-video-files.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 | { | ||
11 | const query = 'DELETE FROM "videoFile" f1 ' + | ||
12 | 'USING (SELECT MIN(id) as id, "torrentFilename" FROM "videoFile" GROUP BY "torrentFilename" HAVING COUNT(*) > 1) f2 ' + | ||
13 | 'WHERE f1."torrentFilename" = f2."torrentFilename" AND f1.id <> f2.id' | ||
14 | await utils.sequelize.query(query) | ||
15 | } | ||
16 | |||
17 | { | ||
18 | const query = 'DELETE FROM "videoFile" f1 ' + | ||
19 | 'USING (SELECT MIN(id) as id, "filename" FROM "videoFile" GROUP BY "filename" HAVING COUNT(*) > 1) f2 ' + | ||
20 | 'WHERE f1."filename" = f2."filename" AND f1.id <> f2.id' | ||
21 | await utils.sequelize.query(query) | ||
22 | } | ||
23 | |||
24 | } | ||
25 | |||
26 | function down (options) { | ||
27 | throw new Error('Not implemented.') | ||
28 | } | ||
29 | |||
30 | export { | ||
31 | up, | ||
32 | down | ||
33 | } | ||
diff --git a/server/initializers/migrations/0605-actor-missing-keys.ts b/server/initializers/migrations/0605-actor-missing-keys.ts deleted file mode 100644 index aa89a500c..000000000 --- a/server/initializers/migrations/0605-actor-missing-keys.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { generateRSAKeyPairPromise } from '../../helpers/core-utils' | ||
3 | import { PRIVATE_RSA_KEY_SIZE } from '../constants' | ||
4 | |||
5 | async function up (utils: { | ||
6 | transaction: Sequelize.Transaction | ||
7 | queryInterface: Sequelize.QueryInterface | ||
8 | sequelize: Sequelize.Sequelize | ||
9 | db: any | ||
10 | }): Promise<void> { | ||
11 | |||
12 | { | ||
13 | const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL' | ||
14 | const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT } | ||
15 | const actors = await utils.sequelize.query<any>(query, options) | ||
16 | |||
17 | for (const actor of actors) { | ||
18 | const { privateKey, publicKey } = await generateRSAKeyPairPromise(PRIVATE_RSA_KEY_SIZE) | ||
19 | |||
20 | const queryUpdate = `UPDATE "actor" SET "publicKey" = '${publicKey}', "privateKey" = '${privateKey}' WHERE id = ${actor.id}` | ||
21 | await utils.sequelize.query(queryUpdate) | ||
22 | } | ||
23 | } | ||
24 | } | ||
25 | |||
26 | function down (options) { | ||
27 | throw new Error('Not implemented.') | ||
28 | } | ||
29 | |||
30 | export { | ||
31 | up, | ||
32 | down | ||
33 | } | ||
diff --git a/server/initializers/migrations/0610-views-index copy.ts b/server/initializers/migrations/0610-views-index copy.ts deleted file mode 100644 index 02ee21172..000000000 --- a/server/initializers/migrations/0610-views-index copy.ts +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
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 | await utils.sequelize.query('DROP INDEX IF EXISTS video_views;') | ||
11 | } | ||
12 | |||
13 | function down (options) { | ||
14 | throw new Error('Not implemented.') | ||
15 | } | ||
16 | |||
17 | export { | ||
18 | up, | ||
19 | down | ||
20 | } | ||
diff --git a/server/initializers/migrations/0612-captions-unique.ts b/server/initializers/migrations/0612-captions-unique.ts deleted file mode 100644 index 368838a2a..000000000 --- a/server/initializers/migrations/0612-captions-unique.ts +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
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 | await utils.sequelize.query( | ||
11 | 'DELETE FROM "videoCaption" v1 USING (SELECT MIN(id) as id, "filename" FROM "videoCaption" ' + | ||
12 | 'GROUP BY "filename" HAVING COUNT(*) > 1) v2 WHERE v1."filename" = v2."filename" AND v1.id <> v2.id' | ||
13 | ) | ||
14 | } | ||
15 | |||
16 | function down (options) { | ||
17 | throw new Error('Not implemented.') | ||
18 | } | ||
19 | |||
20 | export { | ||
21 | up, | ||
22 | down | ||
23 | } | ||
diff --git a/server/initializers/migrations/0615-latest-versions-notification-settings.ts b/server/initializers/migrations/0615-latest-versions-notification-settings.ts deleted file mode 100644 index 86bf56009..000000000 --- a/server/initializers/migrations/0615-latest-versions-notification-settings.ts +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
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 notificationSettingColumns = [ 'newPeerTubeVersion', 'newPluginVersion' ] | ||
11 | |||
12 | for (const column of notificationSettingColumns) { | ||
13 | const data = { | ||
14 | type: Sequelize.INTEGER, | ||
15 | defaultValue: null, | ||
16 | allowNull: true | ||
17 | } | ||
18 | await utils.queryInterface.addColumn('userNotificationSetting', column, data) | ||
19 | } | ||
20 | |||
21 | { | ||
22 | const query = 'UPDATE "userNotificationSetting" SET "newPeerTubeVersion" = 3, "newPluginVersion" = 1' | ||
23 | await utils.sequelize.query(query) | ||
24 | } | ||
25 | |||
26 | for (const column of notificationSettingColumns) { | ||
27 | const data = { | ||
28 | type: Sequelize.INTEGER, | ||
29 | defaultValue: null, | ||
30 | allowNull: false | ||
31 | } | ||
32 | await utils.queryInterface.changeColumn('userNotificationSetting', column, data) | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | |||
37 | function down (options) { | ||
38 | throw new Error('Not implemented.') | ||
39 | } | ||
40 | |||
41 | export { | ||
42 | up, | ||
43 | down | ||
44 | } | ||
diff --git a/server/initializers/migrations/0620-latest-versions-application.ts b/server/initializers/migrations/0620-latest-versions-application.ts deleted file mode 100644 index a689b18fc..000000000 --- a/server/initializers/migrations/0620-latest-versions-application.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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 | { | ||
11 | const data = { | ||
12 | type: Sequelize.STRING, | ||
13 | defaultValue: null, | ||
14 | allowNull: true | ||
15 | } | ||
16 | await utils.queryInterface.addColumn('application', 'latestPeerTubeVersion', data) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0625-latest-versions-notification.ts b/server/initializers/migrations/0625-latest-versions-notification.ts deleted file mode 100644 index 77f395ce4..000000000 --- a/server/initializers/migrations/0625-latest-versions-notification.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
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 | { | ||
11 | await utils.sequelize.query(` | ||
12 | ALTER TABLE "userNotification" | ||
13 | ADD COLUMN "applicationId" INTEGER REFERENCES "application" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
14 | ADD COLUMN "pluginId" INTEGER REFERENCES "plugin" ("id") ON DELETE SET NULL ON UPDATE CASCADE | ||
15 | `) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||
diff --git a/server/initializers/migrations/0630-banner.ts b/server/initializers/migrations/0630-banner.ts deleted file mode 100644 index 5766bb171..000000000 --- a/server/initializers/migrations/0630-banner.ts +++ /dev/null | |||
@@ -1,50 +0,0 @@ | |||
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 | { | ||
11 | await utils.sequelize.query(`ALTER TABLE "avatar" RENAME to "actorImage"`) | ||
12 | } | ||
13 | |||
14 | { | ||
15 | const data = { | ||
16 | type: Sequelize.INTEGER, | ||
17 | defaultValue: null, | ||
18 | allowNull: true | ||
19 | } | ||
20 | await utils.queryInterface.addColumn('actorImage', 'type', data) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | await utils.sequelize.query(`UPDATE "actorImage" SET "type" = 1`) | ||
25 | } | ||
26 | |||
27 | { | ||
28 | const data = { | ||
29 | type: Sequelize.INTEGER, | ||
30 | defaultValue: null, | ||
31 | allowNull: false | ||
32 | } | ||
33 | await utils.queryInterface.changeColumn('actorImage', 'type', data) | ||
34 | } | ||
35 | |||
36 | { | ||
37 | await utils.sequelize.query( | ||
38 | `ALTER TABLE "actor" ADD COLUMN "bannerId" INTEGER REFERENCES "actorImage" ("id") ON DELETE SET NULL ON UPDATE CASCADE` | ||
39 | ) | ||
40 | } | ||
41 | } | ||
42 | |||
43 | function down (options) { | ||
44 | throw new Error('Not implemented.') | ||
45 | } | ||
46 | |||
47 | export { | ||
48 | up, | ||
49 | down | ||
50 | } | ||
diff --git a/server/initializers/migrations/0635-actor-image-size.ts b/server/initializers/migrations/0635-actor-image-size.ts deleted file mode 100644 index d7c5da8c3..000000000 --- a/server/initializers/migrations/0635-actor-image-size.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
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.INTEGER, | ||
12 | defaultValue: null, | ||
13 | allowNull: true | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('actorImage', 'height', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const data = { | ||
20 | type: Sequelize.INTEGER, | ||
21 | defaultValue: null, | ||
22 | allowNull: true | ||
23 | } | ||
24 | await utils.queryInterface.addColumn('actorImage', 'width', data) | ||
25 | } | ||
26 | } | ||
27 | |||
28 | function down (options) { | ||
29 | throw new Error('Not implemented.') | ||
30 | } | ||
31 | |||
32 | export { | ||
33 | up, | ||
34 | down | ||
35 | } | ||
diff --git a/server/initializers/migrations/0640-unique-keys.ts b/server/initializers/migrations/0640-unique-keys.ts deleted file mode 100644 index b082accc2..000000000 --- a/server/initializers/migrations/0640-unique-keys.ts +++ /dev/null | |||
@@ -1,39 +0,0 @@ | |||
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 | await utils.sequelize.query( | ||
11 | 'DELETE FROM "actor" v1 USING (SELECT MIN(id) as id, "preferredUsername", "serverId" FROM "actor" ' + | ||
12 | 'GROUP BY "preferredUsername", "serverId" HAVING COUNT(*) > 1 AND "serverId" IS NOT NULL) v2 ' + | ||
13 | 'WHERE v1."preferredUsername" = v2."preferredUsername" AND v1."serverId" = v2."serverId" AND v1.id <> v2.id' | ||
14 | ) | ||
15 | } | ||
16 | |||
17 | { | ||
18 | await utils.sequelize.query( | ||
19 | 'DELETE FROM "actor" v1 USING (SELECT MIN(id) as id, "url" FROM "actor" GROUP BY "url" HAVING COUNT(*) > 1) v2 ' + | ||
20 | 'WHERE v1."url" = v2."url" AND v1.id <> v2.id' | ||
21 | ) | ||
22 | } | ||
23 | |||
24 | { | ||
25 | await utils.sequelize.query( | ||
26 | 'DELETE FROM "tag" v1 USING (SELECT MIN(id) as id, "name" FROM "tag" GROUP BY "name" HAVING COUNT(*) > 1) v2 ' + | ||
27 | 'WHERE v1."name" = v2."name" AND v1.id <> v2.id' | ||
28 | ) | ||
29 | } | ||
30 | } | ||
31 | |||
32 | function down (options) { | ||
33 | throw new Error('Not implemented.') | ||
34 | } | ||
35 | |||
36 | export { | ||
37 | up, | ||
38 | down | ||
39 | } | ||
diff --git a/server/initializers/migrations/0645-actor-remote-creation-date.ts b/server/initializers/migrations/0645-actor-remote-creation-date.ts deleted file mode 100644 index 38b3b881c..000000000 --- a/server/initializers/migrations/0645-actor-remote-creation-date.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
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.DATE, | ||
12 | defaultValue: null, | ||
13 | allowNull: true | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('actor', 'remoteCreatedAt', data) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||
diff --git a/server/initializers/migrations/0650-actor-custom-pages.ts b/server/initializers/migrations/0650-actor-custom-pages.ts deleted file mode 100644 index 1338327e8..000000000 --- a/server/initializers/migrations/0650-actor-custom-pages.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 query = ` | ||
11 | CREATE TABLE IF NOT EXISTS "actorCustomPage" ( | ||
12 | "id" serial, | ||
13 | "content" TEXT, | ||
14 | "type" varchar(255) NOT NULL, | ||
15 | "actorId" integer NOT NULL REFERENCES "actor" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
16 | "createdAt" timestamp WITH time zone NOT NULL, | ||
17 | "updatedAt" timestamp WITH time zone NOT NULL, | ||
18 | PRIMARY KEY ("id") | ||
19 | ); | ||
20 | ` | ||
21 | |||
22 | await utils.sequelize.query(query) | ||
23 | } | ||
24 | } | ||
25 | |||
26 | function down (options) { | ||
27 | throw new Error('Not implemented.') | ||
28 | } | ||
29 | |||
30 | export { | ||
31 | up, | ||
32 | down | ||
33 | } | ||
diff --git a/server/initializers/migrations/0655-streaming-playlist-filenames.ts b/server/initializers/migrations/0655-streaming-playlist-filenames.ts deleted file mode 100644 index 9172a22c4..000000000 --- a/server/initializers/migrations/0655-streaming-playlist-filenames.ts +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
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 | for (const column of [ 'playlistUrl', 'segmentsSha256Url' ]) { | ||
11 | const data = { | ||
12 | type: Sequelize.STRING, | ||
13 | allowNull: true, | ||
14 | defaultValue: null | ||
15 | } | ||
16 | |||
17 | await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data) | ||
18 | } | ||
19 | } | ||
20 | |||
21 | { | ||
22 | await utils.sequelize.query( | ||
23 | `UPDATE "videoStreamingPlaylist" SET "playlistUrl" = NULL, "segmentsSha256Url" = NULL ` + | ||
24 | `WHERE "videoId" IN (SELECT id FROM video WHERE remote IS FALSE)` | ||
25 | ) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) { | ||
30 | const data = { | ||
31 | type: Sequelize.STRING, | ||
32 | allowNull: true, | ||
33 | defaultValue: null | ||
34 | } | ||
35 | |||
36 | await utils.queryInterface.addColumn('videoStreamingPlaylist', column, data) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | { | ||
41 | await utils.sequelize.query( | ||
42 | `UPDATE "videoStreamingPlaylist" SET "playlistFilename" = 'master.m3u8', "segmentsSha256Filename" = 'segments-sha256.json'` | ||
43 | ) | ||
44 | } | ||
45 | |||
46 | { | ||
47 | for (const column of [ 'playlistFilename', 'segmentsSha256Filename' ]) { | ||
48 | const data = { | ||
49 | type: Sequelize.STRING, | ||
50 | allowNull: false, | ||
51 | defaultValue: null | ||
52 | } | ||
53 | |||
54 | await utils.queryInterface.changeColumn('videoStreamingPlaylist', column, data) | ||
55 | } | ||
56 | } | ||
57 | } | ||
58 | |||
59 | function down (options) { | ||
60 | throw new Error('Not implemented.') | ||
61 | } | ||
62 | |||
63 | export { | ||
64 | up, | ||
65 | down | ||
66 | } | ||
diff --git a/server/initializers/migrations/0660-object-storage.ts b/server/initializers/migrations/0660-object-storage.ts deleted file mode 100644 index 53cb89ce6..000000000 --- a/server/initializers/migrations/0660-object-storage.ts +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { VideoStorage } from '@shared/models' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | db: any | ||
9 | }): Promise<void> { | ||
10 | { | ||
11 | const query = ` | ||
12 | CREATE TABLE IF NOT EXISTS "videoJobInfo" ( | ||
13 | "id" serial, | ||
14 | "pendingMove" INTEGER NOT NULL, | ||
15 | "pendingTranscode" INTEGER NOT NULL, | ||
16 | "videoId" serial UNIQUE NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
17 | "createdAt" timestamp WITH time zone NOT NULL, | ||
18 | "updatedAt" timestamp WITH time zone NOT NULL, | ||
19 | PRIMARY KEY ("id") | ||
20 | ); | ||
21 | ` | ||
22 | |||
23 | await utils.sequelize.query(query) | ||
24 | } | ||
25 | |||
26 | { | ||
27 | await utils.queryInterface.addColumn('videoFile', 'storage', { | ||
28 | type: Sequelize.INTEGER, | ||
29 | allowNull: true, | ||
30 | defaultValue: VideoStorage.FILE_SYSTEM | ||
31 | }) | ||
32 | await utils.queryInterface.changeColumn('videoFile', 'storage', { type: Sequelize.INTEGER, allowNull: false, defaultValue: null }) | ||
33 | } | ||
34 | |||
35 | { | ||
36 | await utils.queryInterface.addColumn('videoStreamingPlaylist', 'storage', { | ||
37 | type: Sequelize.INTEGER, | ||
38 | allowNull: true, | ||
39 | defaultValue: VideoStorage.FILE_SYSTEM | ||
40 | }) | ||
41 | await utils.queryInterface.changeColumn('videoStreamingPlaylist', 'storage', { | ||
42 | type: Sequelize.INTEGER, | ||
43 | allowNull: false, | ||
44 | defaultValue: null | ||
45 | }) | ||
46 | } | ||
47 | } | ||
48 | |||
49 | function down (options) { | ||
50 | throw new Error('Not implemented.') | ||
51 | } | ||
52 | |||
53 | export { | ||
54 | up, | ||
55 | down | ||
56 | } | ||
diff --git a/server/initializers/migrations/0665-no-account-warning-modal.ts b/server/initializers/migrations/0665-no-account-warning-modal.ts deleted file mode 100644 index 6718aed85..000000000 --- a/server/initializers/migrations/0665-no-account-warning-modal.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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.BOOLEAN, | ||
12 | allowNull: false, | ||
13 | defaultValue: false | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('user', 'noAccountSetupWarningModal', data) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0670-pending-job-default.ts b/server/initializers/migrations/0670-pending-job-default.ts deleted file mode 100644 index 7e9def1a0..000000000 --- a/server/initializers/migrations/0670-pending-job-default.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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 | for (const column of [ 'pendingMove', 'pendingTranscode' ]) { | ||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: false, | ||
13 | defaultValue: 0 | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.changeColumn('videoJobInfo', column, data) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0675-p2p-enabled.ts b/server/initializers/migrations/0675-p2p-enabled.ts deleted file mode 100644 index b4f53381e..000000000 --- a/server/initializers/migrations/0675-p2p-enabled.ts +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
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 | await utils.queryInterface.renameColumn('user', 'webTorrentEnabled', 'p2pEnabled') | ||
10 | |||
11 | await utils.sequelize.query('ALTER TABLE "user" ALTER COLUMN "p2pEnabled" DROP DEFAULT') | ||
12 | } | ||
13 | |||
14 | function down (options) { | ||
15 | throw new Error('Not implemented.') | ||
16 | } | ||
17 | |||
18 | export { | ||
19 | up, | ||
20 | down | ||
21 | } | ||
diff --git a/server/initializers/migrations/0680-files-storage-default.ts b/server/initializers/migrations/0680-files-storage-default.ts deleted file mode 100644 index 087bc8790..000000000 --- a/server/initializers/migrations/0680-files-storage-default.ts +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
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 | await utils.sequelize.query('ALTER TABLE "videoFile" ALTER COLUMN "storage" SET DEFAULT 0') | ||
10 | await utils.sequelize.query('ALTER TABLE "videoStreamingPlaylist" ALTER COLUMN "storage" SET DEFAULT 0') | ||
11 | } | ||
12 | |||
13 | function down (options) { | ||
14 | throw new Error('Not implemented.') | ||
15 | } | ||
16 | |||
17 | export { | ||
18 | up, | ||
19 | down | ||
20 | } | ||
diff --git a/server/initializers/migrations/0685-multiple-actor-images.ts b/server/initializers/migrations/0685-multiple-actor-images.ts deleted file mode 100644 index c656f7e28..000000000 --- a/server/initializers/migrations/0685-multiple-actor-images.ts +++ /dev/null | |||
@@ -1,62 +0,0 @@ | |||
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 | await utils.queryInterface.addColumn('actorImage', 'actorId', { | ||
11 | type: Sequelize.INTEGER, | ||
12 | defaultValue: null, | ||
13 | allowNull: true, | ||
14 | references: { | ||
15 | model: 'actor', | ||
16 | key: 'id' | ||
17 | }, | ||
18 | onDelete: 'CASCADE' | ||
19 | }, { transaction: utils.transaction }) | ||
20 | |||
21 | // Avatars | ||
22 | { | ||
23 | const query = `UPDATE "actorImage" SET "actorId" = (SELECT "id" FROM "actor" WHERE "actor"."avatarId" = "actorImage"."id") ` + | ||
24 | `WHERE "type" = 1` | ||
25 | await utils.sequelize.query(query, { type: Sequelize.QueryTypes.UPDATE, transaction: utils.transaction }) | ||
26 | } | ||
27 | |||
28 | // Banners | ||
29 | { | ||
30 | const query = `UPDATE "actorImage" SET "actorId" = (SELECT "id" FROM "actor" WHERE "actor"."bannerId" = "actorImage"."id") ` + | ||
31 | `WHERE "type" = 2` | ||
32 | await utils.sequelize.query(query, { type: Sequelize.QueryTypes.UPDATE, transaction: utils.transaction }) | ||
33 | } | ||
34 | |||
35 | // Remove orphans | ||
36 | { | ||
37 | const query = `DELETE FROM "actorImage" WHERE id NOT IN (` + | ||
38 | `SELECT "bannerId" FROM actor WHERE "bannerId" IS NOT NULL ` + | ||
39 | `UNION select "avatarId" FROM actor WHERE "avatarId" IS NOT NULL` + | ||
40 | `);` | ||
41 | |||
42 | await utils.sequelize.query(query, { type: Sequelize.QueryTypes.DELETE, transaction: utils.transaction }) | ||
43 | } | ||
44 | |||
45 | await utils.queryInterface.changeColumn('actorImage', 'actorId', { | ||
46 | type: Sequelize.INTEGER, | ||
47 | allowNull: false | ||
48 | }, { transaction: utils.transaction }) | ||
49 | |||
50 | await utils.queryInterface.removeColumn('actor', 'avatarId', { transaction: utils.transaction }) | ||
51 | await utils.queryInterface.removeColumn('actor', 'bannerId', { transaction: utils.transaction }) | ||
52 | } | ||
53 | } | ||
54 | |||
55 | function down () { | ||
56 | throw new Error('Not implemented.') | ||
57 | } | ||
58 | |||
59 | export { | ||
60 | up, | ||
61 | down | ||
62 | } | ||
diff --git a/server/initializers/migrations/0690-live-latency-mode.ts b/server/initializers/migrations/0690-live-latency-mode.ts deleted file mode 100644 index c31a61364..000000000 --- a/server/initializers/migrations/0690-live-latency-mode.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | import { LiveVideoLatencyMode } from '@shared/models' | ||
2 | import * as Sequelize from 'sequelize' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | db: any | ||
9 | }): Promise<void> { | ||
10 | await utils.queryInterface.addColumn('videoLive', 'latencyMode', { | ||
11 | type: Sequelize.INTEGER, | ||
12 | defaultValue: null, | ||
13 | allowNull: true | ||
14 | }, { transaction: utils.transaction }) | ||
15 | |||
16 | { | ||
17 | const query = `UPDATE "videoLive" SET "latencyMode" = ${LiveVideoLatencyMode.DEFAULT}` | ||
18 | await utils.sequelize.query(query, { type: Sequelize.QueryTypes.UPDATE, transaction: utils.transaction }) | ||
19 | } | ||
20 | |||
21 | await utils.queryInterface.changeColumn('videoLive', 'latencyMode', { | ||
22 | type: Sequelize.INTEGER, | ||
23 | defaultValue: null, | ||
24 | allowNull: false | ||
25 | }, { transaction: utils.transaction }) | ||
26 | } | ||
27 | |||
28 | function down () { | ||
29 | throw new Error('Not implemented.') | ||
30 | } | ||
31 | |||
32 | export { | ||
33 | up, | ||
34 | down | ||
35 | } | ||
diff --git a/server/initializers/migrations/0695-remove-remote-rates.ts b/server/initializers/migrations/0695-remove-remote-rates.ts deleted file mode 100644 index f5c394bae..000000000 --- a/server/initializers/migrations/0695-remove-remote-rates.ts +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
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 | const query = 'DELETE FROM "accountVideoRate" ' + | ||
10 | 'WHERE "accountVideoRate".id IN (' + | ||
11 | 'SELECT "accountVideoRate".id FROM "accountVideoRate" ' + | ||
12 | 'INNER JOIN account ON account.id = "accountVideoRate"."accountId" ' + | ||
13 | 'INNER JOIN actor ON actor.id = account."actorId" ' + | ||
14 | 'INNER JOIN video ON video.id = "accountVideoRate"."videoId" ' + | ||
15 | 'WHERE actor."serverId" IS NOT NULL AND video.remote IS TRUE' + | ||
16 | ')' | ||
17 | |||
18 | await utils.sequelize.query(query, { type: Sequelize.QueryTypes.BULKDELETE, transaction: utils.transaction }) | ||
19 | } | ||
20 | |||
21 | function down () { | ||
22 | throw new Error('Not implemented.') | ||
23 | } | ||
24 | |||
25 | export { | ||
26 | up, | ||
27 | down | ||
28 | } | ||
diff --git a/server/initializers/migrations/0700-edition-finished-notification.ts b/server/initializers/migrations/0700-edition-finished-notification.ts deleted file mode 100644 index 5310eab3f..000000000 --- a/server/initializers/migrations/0700-edition-finished-notification.ts +++ /dev/null | |||
@@ -1,42 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | { | ||
12 | const data = { | ||
13 | type: Sequelize.INTEGER, | ||
14 | defaultValue: null, | ||
15 | allowNull: true | ||
16 | } | ||
17 | await utils.queryInterface.addColumn('userNotificationSetting', 'myVideoStudioEditionFinished', data, { transaction }) | ||
18 | } | ||
19 | |||
20 | { | ||
21 | const query = 'UPDATE "userNotificationSetting" SET "myVideoStudioEditionFinished" = 1' | ||
22 | await utils.sequelize.query(query, { transaction }) | ||
23 | } | ||
24 | |||
25 | { | ||
26 | const data = { | ||
27 | type: Sequelize.INTEGER, | ||
28 | defaultValue: null, | ||
29 | allowNull: false | ||
30 | } | ||
31 | await utils.queryInterface.changeColumn('userNotificationSetting', 'myVideoStudioEditionFinished', data, { transaction }) | ||
32 | } | ||
33 | } | ||
34 | |||
35 | function down () { | ||
36 | throw new Error('Not implemented.') | ||
37 | } | ||
38 | |||
39 | export { | ||
40 | up, | ||
41 | down | ||
42 | } | ||
diff --git a/server/initializers/migrations/0705-local-video-viewers.ts b/server/initializers/migrations/0705-local-video-viewers.ts deleted file mode 100644 index 123402641..000000000 --- a/server/initializers/migrations/0705-local-video-viewers.ts +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | { | ||
12 | const query = ` | ||
13 | CREATE TABLE IF NOT EXISTS "localVideoViewer" ( | ||
14 | "id" serial, | ||
15 | "startDate" timestamp with time zone NOT NULL, | ||
16 | "endDate" timestamp with time zone NOT NULL, | ||
17 | "watchTime" integer NOT NULL, | ||
18 | "country" varchar(255), | ||
19 | "uuid" uuid NOT NULL, | ||
20 | "url" varchar(255) NOT NULL, | ||
21 | "videoId" integer NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
22 | "createdAt" timestamp with time zone NOT NULL, | ||
23 | PRIMARY KEY ("id") | ||
24 | ); | ||
25 | ` | ||
26 | await utils.sequelize.query(query, { transaction }) | ||
27 | } | ||
28 | |||
29 | { | ||
30 | const query = ` | ||
31 | CREATE TABLE IF NOT EXISTS "localVideoViewerWatchSection" ( | ||
32 | "id" serial, | ||
33 | "watchStart" integer NOT NULL, | ||
34 | "watchEnd" integer NOT NULL, | ||
35 | "localVideoViewerId" integer NOT NULL REFERENCES "localVideoViewer" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
36 | "createdAt" timestamp with time zone NOT NULL, | ||
37 | PRIMARY KEY ("id") | ||
38 | ); | ||
39 | ` | ||
40 | await utils.sequelize.query(query, { transaction }) | ||
41 | } | ||
42 | |||
43 | } | ||
44 | |||
45 | function down () { | ||
46 | throw new Error('Not implemented.') | ||
47 | } | ||
48 | |||
49 | export { | ||
50 | up, | ||
51 | down | ||
52 | } | ||
diff --git a/server/initializers/migrations/0710-live-sessions.ts b/server/initializers/migrations/0710-live-sessions.ts deleted file mode 100644 index aaac8d9ce..000000000 --- a/server/initializers/migrations/0710-live-sessions.ts +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | const query = ` | ||
12 | CREATE TABLE IF NOT EXISTS "videoLiveSession" ( | ||
13 | "id" serial, | ||
14 | "startDate" timestamp with time zone NOT NULL, | ||
15 | "endDate" timestamp with time zone, | ||
16 | "error" integer, | ||
17 | "replayVideoId" integer REFERENCES "video" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
18 | "liveVideoId" integer REFERENCES "video" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
19 | "createdAt" timestamp with time zone NOT NULL, | ||
20 | "updatedAt" timestamp with time zone NOT NULL, | ||
21 | PRIMARY KEY ("id") | ||
22 | ); | ||
23 | ` | ||
24 | await utils.sequelize.query(query, { transaction }) | ||
25 | } | ||
26 | |||
27 | function down () { | ||
28 | throw new Error('Not implemented.') | ||
29 | } | ||
30 | |||
31 | export { | ||
32 | up, | ||
33 | down | ||
34 | } | ||
diff --git a/server/initializers/migrations/0715-video-source.ts b/server/initializers/migrations/0715-video-source.ts deleted file mode 100644 index efcf77ebd..000000000 --- a/server/initializers/migrations/0715-video-source.ts +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
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 query = ` | ||
11 | CREATE TABLE IF NOT EXISTS "videoSource" ( | ||
12 | "id" SERIAL , | ||
13 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
14 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
15 | "filename" VARCHAR(255) DEFAULT NULL, | ||
16 | "videoId" INTEGER | ||
17 | REFERENCES "video" ("id") | ||
18 | ON DELETE CASCADE | ||
19 | ON UPDATE CASCADE, | ||
20 | PRIMARY KEY ("id") | ||
21 | ); | ||
22 | ` | ||
23 | await utils.sequelize.query(query) | ||
24 | } | ||
25 | } | ||
26 | |||
27 | function down (options) { | ||
28 | throw new Error('Not implemented.') | ||
29 | } | ||
30 | |||
31 | export { | ||
32 | up, | ||
33 | down | ||
34 | } | ||
diff --git a/server/initializers/migrations/0720-session-ending-processed.ts b/server/initializers/migrations/0720-session-ending-processed.ts deleted file mode 100644 index 74ffb39a0..000000000 --- a/server/initializers/migrations/0720-session-ending-processed.ts +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | { | ||
12 | const data = { | ||
13 | type: Sequelize.BOOLEAN, | ||
14 | defaultValue: null, | ||
15 | allowNull: true | ||
16 | } | ||
17 | await utils.queryInterface.addColumn('videoLiveSession', 'endingProcessed', data, { transaction }) | ||
18 | await utils.queryInterface.addColumn('videoLiveSession', 'saveReplay', data, { transaction }) | ||
19 | } | ||
20 | |||
21 | { | ||
22 | const query = `UPDATE "videoLiveSession" SET "saveReplay" = ( | ||
23 | SELECT "videoLive"."saveReplay" FROM "videoLive" WHERE "videoLive"."videoId" = "videoLiveSession"."liveVideoId" | ||
24 | ) WHERE "videoLiveSession"."liveVideoId" IS NOT NULL` | ||
25 | await utils.sequelize.query(query, { transaction }) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | const query = `UPDATE "videoLiveSession" SET "saveReplay" = FALSE WHERE "saveReplay" IS NULL` | ||
30 | await utils.sequelize.query(query, { transaction }) | ||
31 | } | ||
32 | |||
33 | { | ||
34 | const query = `UPDATE "videoLiveSession" SET "endingProcessed" = TRUE` | ||
35 | await utils.sequelize.query(query, { transaction }) | ||
36 | } | ||
37 | |||
38 | { | ||
39 | const data = { | ||
40 | type: Sequelize.BOOLEAN, | ||
41 | defaultValue: null, | ||
42 | allowNull: false | ||
43 | } | ||
44 | await utils.queryInterface.changeColumn('videoLiveSession', 'endingProcessed', data, { transaction }) | ||
45 | await utils.queryInterface.changeColumn('videoLiveSession', 'saveReplay', data, { transaction }) | ||
46 | } | ||
47 | } | ||
48 | |||
49 | function down (options) { | ||
50 | throw new Error('Not implemented.') | ||
51 | } | ||
52 | |||
53 | export { | ||
54 | up, | ||
55 | down | ||
56 | } | ||
diff --git a/server/initializers/migrations/0725-node-version.ts b/server/initializers/migrations/0725-node-version.ts deleted file mode 100644 index d8b9cc750..000000000 --- a/server/initializers/migrations/0725-node-version.ts +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | { | ||
12 | const data = { | ||
13 | type: Sequelize.STRING, | ||
14 | defaultValue: null, | ||
15 | allowNull: true | ||
16 | } | ||
17 | await utils.queryInterface.addColumn('application', 'nodeVersion', data, { transaction }) | ||
18 | } | ||
19 | |||
20 | { | ||
21 | const data = { | ||
22 | type: Sequelize.STRING, | ||
23 | defaultValue: null, | ||
24 | allowNull: true | ||
25 | } | ||
26 | await utils.queryInterface.addColumn('application', 'nodeABIVersion', data, { transaction }) | ||
27 | } | ||
28 | |||
29 | { | ||
30 | const query = `UPDATE "application" SET "nodeVersion" = '${process.version}'` | ||
31 | await utils.sequelize.query(query, { transaction }) | ||
32 | } | ||
33 | |||
34 | { | ||
35 | const nodeABIVersion = parseInt(process.versions.modules) | ||
36 | const query = `UPDATE "application" SET "nodeABIVersion" = ${nodeABIVersion}` | ||
37 | await utils.sequelize.query(query, { transaction }) | ||
38 | } | ||
39 | |||
40 | { | ||
41 | const data = { | ||
42 | type: Sequelize.STRING, | ||
43 | defaultValue: null, | ||
44 | allowNull: false | ||
45 | } | ||
46 | await utils.queryInterface.changeColumn('application', 'nodeVersion', data, { transaction }) | ||
47 | } | ||
48 | |||
49 | { | ||
50 | const data = { | ||
51 | type: Sequelize.STRING, | ||
52 | defaultValue: null, | ||
53 | allowNull: false | ||
54 | } | ||
55 | await utils.queryInterface.changeColumn('application', 'nodeABIVersion', data, { transaction }) | ||
56 | } | ||
57 | } | ||
58 | |||
59 | function down (options) { | ||
60 | throw new Error('Not implemented.') | ||
61 | } | ||
62 | |||
63 | export { | ||
64 | up, | ||
65 | down | ||
66 | } | ||
diff --git a/server/initializers/migrations/0730-video-channel-sync.ts b/server/initializers/migrations/0730-video-channel-sync.ts deleted file mode 100644 index a2fe8211f..000000000 --- a/server/initializers/migrations/0730-video-channel-sync.ts +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
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 | const query = ` | ||
10 | CREATE TABLE IF NOT EXISTS "videoChannelSync" ( | ||
11 | "id" SERIAL, | ||
12 | "externalChannelUrl" VARCHAR(2000) NOT NULL DEFAULT NULL, | ||
13 | "videoChannelId" INTEGER NOT NULL REFERENCES "videoChannel" ("id") | ||
14 | ON DELETE CASCADE | ||
15 | ON UPDATE CASCADE, | ||
16 | "state" INTEGER NOT NULL DEFAULT 1, | ||
17 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
18 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
19 | "lastSyncAt" TIMESTAMP WITH TIME ZONE, | ||
20 | PRIMARY KEY ("id") | ||
21 | ); | ||
22 | ` | ||
23 | await utils.sequelize.query(query, { transaction: utils.transaction }) | ||
24 | } | ||
25 | |||
26 | async function down (utils: { | ||
27 | queryInterface: Sequelize.QueryInterface | ||
28 | transaction: Sequelize.Transaction | ||
29 | }) { | ||
30 | await utils.queryInterface.dropTable('videoChannelSync', { transaction: utils.transaction }) | ||
31 | } | ||
32 | |||
33 | export { | ||
34 | up, | ||
35 | down | ||
36 | } | ||
diff --git a/server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts b/server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts deleted file mode 100644 index ffe0b11ab..000000000 --- a/server/initializers/migrations/0735-video-channel-sync-import-foreign-key.ts +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
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 | await utils.queryInterface.addColumn('videoImport', 'videoChannelSyncId', { | ||
10 | type: Sequelize.INTEGER, | ||
11 | defaultValue: null, | ||
12 | allowNull: true, | ||
13 | references: { | ||
14 | model: 'videoChannelSync', | ||
15 | key: 'id' | ||
16 | }, | ||
17 | onUpdate: 'CASCADE', | ||
18 | onDelete: 'SET NULL' | ||
19 | }, { transaction: utils.transaction }) | ||
20 | } | ||
21 | |||
22 | async function down (utils: { | ||
23 | queryInterface: Sequelize.QueryInterface | ||
24 | transaction: Sequelize.Transaction | ||
25 | }) { | ||
26 | await utils.queryInterface.dropTable('videoChannelSync', { transaction: utils.transaction }) | ||
27 | } | ||
28 | |||
29 | export { | ||
30 | up, | ||
31 | down | ||
32 | } | ||
diff --git a/server/initializers/migrations/0740-fix-old-enums.ts b/server/initializers/migrations/0740-fix-old-enums.ts deleted file mode 100644 index 501d0ccb2..000000000 --- a/server/initializers/migrations/0740-fix-old-enums.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
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 | try { | ||
10 | await utils.sequelize.query('drop type "enum_actorFollow_state"') | ||
11 | await utils.sequelize.query('alter type "enum_AccountFollows_state" rename to "enum_actorFollow_state";') | ||
12 | } catch { | ||
13 | // empty | ||
14 | } | ||
15 | |||
16 | try { | ||
17 | await utils.sequelize.query('drop type "enum_accountVideoRate_type"') | ||
18 | await utils.sequelize.query('alter type "enum_AccountVideoRates_type" rename to "enum_accountVideoRate_type";') | ||
19 | } catch { | ||
20 | // empty | ||
21 | } | ||
22 | } | ||
23 | |||
24 | async function down (utils: { | ||
25 | queryInterface: Sequelize.QueryInterface | ||
26 | transaction: Sequelize.Transaction | ||
27 | }) { | ||
28 | } | ||
29 | |||
30 | export { | ||
31 | up, | ||
32 | down | ||
33 | } | ||
diff --git a/server/initializers/migrations/0745-user-otp.ts b/server/initializers/migrations/0745-user-otp.ts deleted file mode 100644 index 157308ea1..000000000 --- a/server/initializers/migrations/0745-user-otp.ts +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.STRING, | ||
13 | defaultValue: null, | ||
14 | allowNull: true | ||
15 | } | ||
16 | await utils.queryInterface.addColumn('user', 'otpSecret', data, { transaction }) | ||
17 | |||
18 | } | ||
19 | |||
20 | async function down (utils: { | ||
21 | queryInterface: Sequelize.QueryInterface | ||
22 | transaction: Sequelize.Transaction | ||
23 | }) { | ||
24 | } | ||
25 | |||
26 | export { | ||
27 | up, | ||
28 | down | ||
29 | } | ||
diff --git a/server/initializers/migrations/0750-user-registration.ts b/server/initializers/migrations/0750-user-registration.ts deleted file mode 100644 index 15bbfd3fd..000000000 --- a/server/initializers/migrations/0750-user-registration.ts +++ /dev/null | |||
@@ -1,58 +0,0 @@ | |||
1 | |||
2 | import * as Sequelize from 'sequelize' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | db: any | ||
9 | }): Promise<void> { | ||
10 | { | ||
11 | const query = ` | ||
12 | CREATE TABLE IF NOT EXISTS "userRegistration" ( | ||
13 | "id" serial, | ||
14 | "state" integer NOT NULL, | ||
15 | "registrationReason" text NOT NULL, | ||
16 | "moderationResponse" text, | ||
17 | "password" varchar(255), | ||
18 | "username" varchar(255) NOT NULL, | ||
19 | "email" varchar(400) NOT NULL, | ||
20 | "emailVerified" boolean, | ||
21 | "accountDisplayName" varchar(255), | ||
22 | "channelHandle" varchar(255), | ||
23 | "channelDisplayName" varchar(255), | ||
24 | "userId" integer REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
25 | "createdAt" timestamp with time zone NOT NULL, | ||
26 | "updatedAt" timestamp with time zone NOT NULL, | ||
27 | PRIMARY KEY ("id") | ||
28 | ); | ||
29 | ` | ||
30 | await utils.sequelize.query(query, { transaction: utils.transaction }) | ||
31 | } | ||
32 | |||
33 | { | ||
34 | await utils.queryInterface.addColumn('userNotification', 'userRegistrationId', { | ||
35 | type: Sequelize.INTEGER, | ||
36 | defaultValue: null, | ||
37 | allowNull: true, | ||
38 | references: { | ||
39 | model: 'userRegistration', | ||
40 | key: 'id' | ||
41 | }, | ||
42 | onUpdate: 'CASCADE', | ||
43 | onDelete: 'SET NULL' | ||
44 | }, { transaction: utils.transaction }) | ||
45 | } | ||
46 | } | ||
47 | |||
48 | async function down (utils: { | ||
49 | queryInterface: Sequelize.QueryInterface | ||
50 | transaction: Sequelize.Transaction | ||
51 | }) { | ||
52 | await utils.queryInterface.dropTable('videoChannelSync', { transaction: utils.transaction }) | ||
53 | } | ||
54 | |||
55 | export { | ||
56 | up, | ||
57 | down | ||
58 | } | ||
diff --git a/server/initializers/migrations/0755-unique-viewer-url.ts b/server/initializers/migrations/0755-unique-viewer-url.ts deleted file mode 100644 index b3dff9258..000000000 --- a/server/initializers/migrations/0755-unique-viewer-url.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | const query = 'DELETE FROM "localVideoViewer" t1 ' + | ||
12 | 'USING (SELECT MIN(id) as id, "url" FROM "localVideoViewer" GROUP BY "url" HAVING COUNT(*) > 1) t2 ' + | ||
13 | 'WHERE t1."url" = t2."url" AND t1.id <> t2.id' | ||
14 | |||
15 | await utils.sequelize.query(query, { transaction }) | ||
16 | } | ||
17 | |||
18 | async function down (utils: { | ||
19 | queryInterface: Sequelize.QueryInterface | ||
20 | transaction: Sequelize.Transaction | ||
21 | }) { | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/initializers/migrations/0760-video-live-replay-setting.ts b/server/initializers/migrations/0760-video-live-replay-setting.ts deleted file mode 100644 index 7878df3f7..000000000 --- a/server/initializers/migrations/0760-video-live-replay-setting.ts +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | { | ||
9 | const query = ` | ||
10 | CREATE TABLE IF NOT EXISTS "videoLiveReplaySetting" ( | ||
11 | "id" SERIAL , | ||
12 | "privacy" INTEGER NOT NULL, | ||
13 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
14 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
15 | PRIMARY KEY ("id") | ||
16 | ); | ||
17 | ` | ||
18 | |||
19 | await utils.sequelize.query(query, { transaction : utils.transaction }) | ||
20 | } | ||
21 | |||
22 | { | ||
23 | await utils.queryInterface.addColumn('videoLive', 'replaySettingId', { | ||
24 | type: Sequelize.INTEGER, | ||
25 | defaultValue: null, | ||
26 | allowNull: true, | ||
27 | references: { | ||
28 | model: 'videoLiveReplaySetting', | ||
29 | key: 'id' | ||
30 | }, | ||
31 | onDelete: 'SET NULL' | ||
32 | }, { transaction: utils.transaction }) | ||
33 | } | ||
34 | |||
35 | { | ||
36 | await utils.queryInterface.addColumn('videoLiveSession', 'replaySettingId', { | ||
37 | type: Sequelize.INTEGER, | ||
38 | defaultValue: null, | ||
39 | allowNull: true, | ||
40 | references: { | ||
41 | model: 'videoLiveReplaySetting', | ||
42 | key: 'id' | ||
43 | }, | ||
44 | onDelete: 'SET NULL' | ||
45 | }, { transaction: utils.transaction }) | ||
46 | } | ||
47 | |||
48 | { | ||
49 | const query = ` | ||
50 | SELECT live."id", v."privacy" | ||
51 | FROM "videoLive" live | ||
52 | INNER JOIN "video" v ON live."videoId" = v."id" | ||
53 | WHERE live."saveReplay" = true | ||
54 | ` | ||
55 | |||
56 | const videoLives = await utils.sequelize.query<{ id: number, privacy: number }>( | ||
57 | query, | ||
58 | { type: Sequelize.QueryTypes.SELECT, transaction: utils.transaction } | ||
59 | ) | ||
60 | |||
61 | for (const videoLive of videoLives) { | ||
62 | const query = ` | ||
63 | WITH new_replay_setting AS ( | ||
64 | INSERT INTO "videoLiveReplaySetting" ("privacy", "createdAt", "updatedAt") | ||
65 | VALUES (:privacy, NOW(), NOW()) | ||
66 | RETURNING id | ||
67 | ) | ||
68 | UPDATE "videoLive" SET "replaySettingId" = (SELECT id FROM new_replay_setting) | ||
69 | WHERE "id" = :id | ||
70 | ` | ||
71 | |||
72 | const options = { | ||
73 | replacements: { privacy: videoLive.privacy, id: videoLive.id }, | ||
74 | type: Sequelize.QueryTypes.UPDATE, | ||
75 | transaction: utils.transaction | ||
76 | } | ||
77 | |||
78 | await utils.sequelize.query(query, options) | ||
79 | } | ||
80 | } | ||
81 | |||
82 | { | ||
83 | const query = ` | ||
84 | SELECT session."id", v."privacy" | ||
85 | FROM "videoLiveSession" session | ||
86 | INNER JOIN "video" v ON session."liveVideoId" = v."id" | ||
87 | WHERE session."saveReplay" = true | ||
88 | AND session."liveVideoId" IS NOT NULL; | ||
89 | ` | ||
90 | |||
91 | const videoLiveSessions = await utils.sequelize.query<{ id: number, privacy: number }>( | ||
92 | query, | ||
93 | { type: Sequelize.QueryTypes.SELECT, transaction: utils.transaction } | ||
94 | ) | ||
95 | |||
96 | for (const videoLive of videoLiveSessions) { | ||
97 | const query = ` | ||
98 | WITH new_replay_setting AS ( | ||
99 | INSERT INTO "videoLiveReplaySetting" ("privacy", "createdAt", "updatedAt") | ||
100 | VALUES (:privacy, NOW(), NOW()) | ||
101 | RETURNING id | ||
102 | ) | ||
103 | UPDATE "videoLiveSession" SET "replaySettingId" = (SELECT id FROM new_replay_setting) | ||
104 | WHERE "id" = :id | ||
105 | ` | ||
106 | |||
107 | const options = { | ||
108 | replacements: { privacy: videoLive.privacy, id: videoLive.id }, | ||
109 | type: Sequelize.QueryTypes.UPDATE, | ||
110 | transaction: utils.transaction | ||
111 | } | ||
112 | |||
113 | await utils.sequelize.query(query, options) | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | |||
118 | function down (options) { | ||
119 | throw new Error('Not implemented.') | ||
120 | } | ||
121 | |||
122 | export { | ||
123 | up, | ||
124 | down | ||
125 | } | ||
diff --git a/server/initializers/migrations/0765-remote-transcoding.ts b/server/initializers/migrations/0765-remote-transcoding.ts deleted file mode 100644 index 40cca03b4..000000000 --- a/server/initializers/migrations/0765-remote-transcoding.ts +++ /dev/null | |||
@@ -1,78 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | { | ||
9 | const query = ` | ||
10 | CREATE TABLE IF NOT EXISTS "runnerRegistrationToken"( | ||
11 | "id" serial, | ||
12 | "registrationToken" varchar(255) NOT NULL, | ||
13 | "createdAt" timestamp with time zone NOT NULL, | ||
14 | "updatedAt" timestamp with time zone NOT NULL, | ||
15 | PRIMARY KEY ("id") | ||
16 | ); | ||
17 | ` | ||
18 | |||
19 | await utils.sequelize.query(query, { transaction : utils.transaction }) | ||
20 | } | ||
21 | |||
22 | { | ||
23 | const query = ` | ||
24 | CREATE TABLE IF NOT EXISTS "runner"( | ||
25 | "id" serial, | ||
26 | "runnerToken" varchar(255) NOT NULL, | ||
27 | "name" varchar(255) NOT NULL, | ||
28 | "description" varchar(1000), | ||
29 | "lastContact" timestamp with time zone NOT NULL, | ||
30 | "ip" varchar(255) NOT NULL, | ||
31 | "runnerRegistrationTokenId" integer REFERENCES "runnerRegistrationToken"("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
32 | "createdAt" timestamp with time zone NOT NULL, | ||
33 | "updatedAt" timestamp with time zone NOT NULL, | ||
34 | PRIMARY KEY ("id") | ||
35 | ); | ||
36 | ` | ||
37 | |||
38 | await utils.sequelize.query(query, { transaction : utils.transaction }) | ||
39 | } | ||
40 | |||
41 | { | ||
42 | const query = ` | ||
43 | CREATE TABLE IF NOT EXISTS "runnerJob"( | ||
44 | "id" serial, | ||
45 | "uuid" uuid NOT NULL, | ||
46 | "type" varchar(255) NOT NULL, | ||
47 | "payload" jsonb NOT NULL, | ||
48 | "privatePayload" jsonb NOT NULL, | ||
49 | "state" integer NOT NULL, | ||
50 | "failures" integer NOT NULL DEFAULT 0, | ||
51 | "error" varchar(5000), | ||
52 | "priority" integer NOT NULL, | ||
53 | "processingJobToken" varchar(255), | ||
54 | "progress" integer, | ||
55 | "startedAt" timestamp with time zone, | ||
56 | "finishedAt" timestamp with time zone, | ||
57 | "dependsOnRunnerJobId" integer REFERENCES "runnerJob"("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
58 | "runnerId" integer REFERENCES "runner"("id") ON DELETE SET NULL ON UPDATE CASCADE, | ||
59 | "createdAt" timestamp with time zone NOT NULL, | ||
60 | "updatedAt" timestamp with time zone NOT NULL, | ||
61 | PRIMARY KEY ("id") | ||
62 | ); | ||
63 | |||
64 | |||
65 | ` | ||
66 | |||
67 | await utils.sequelize.query(query, { transaction : utils.transaction }) | ||
68 | } | ||
69 | } | ||
70 | |||
71 | function down (options) { | ||
72 | throw new Error('Not implemented.') | ||
73 | } | ||
74 | |||
75 | export { | ||
76 | up, | ||
77 | down | ||
78 | } | ||
diff --git a/server/initializers/migrations/0770-actor-preferred-username.ts b/server/initializers/migrations/0770-actor-preferred-username.ts deleted file mode 100644 index 217813f7f..000000000 --- a/server/initializers/migrations/0770-actor-preferred-username.ts +++ /dev/null | |||
@@ -1,44 +0,0 @@ | |||
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 | const { transaction } = utils | ||
10 | |||
11 | await utils.sequelize.query('drop index if exists "actor_preferred_username"', { transaction }) | ||
12 | await utils.sequelize.query('drop index if exists "actor_preferred_username_server_id"', { transaction }) | ||
13 | |||
14 | await utils.sequelize.query( | ||
15 | 'DELETE FROM "actor" v1 USING (' + | ||
16 | 'SELECT MIN(id) as id, lower("preferredUsername") AS "lowerPreferredUsername", "serverId" ' + | ||
17 | 'FROM "actor" ' + | ||
18 | 'GROUP BY "lowerPreferredUsername", "serverId" HAVING COUNT(*) > 1 AND "serverId" IS NOT NULL' + | ||
19 | ') v2 ' + | ||
20 | 'WHERE lower(v1."preferredUsername") = v2."lowerPreferredUsername" AND v1."serverId" = v2."serverId" AND v1.id <> v2.id', | ||
21 | { transaction } | ||
22 | ) | ||
23 | |||
24 | await utils.sequelize.query( | ||
25 | 'DELETE FROM "actor" v1 USING (' + | ||
26 | 'SELECT MIN(id) as id, lower("preferredUsername") AS "lowerPreferredUsername", "serverId" ' + | ||
27 | 'FROM "actor" ' + | ||
28 | 'GROUP BY "lowerPreferredUsername", "serverId" HAVING COUNT(*) > 1 AND "serverId" IS NULL' + | ||
29 | ') v2 ' + | ||
30 | 'WHERE lower(v1."preferredUsername") = v2."lowerPreferredUsername" AND v1."serverId" IS NULL AND v1.id <> v2.id', | ||
31 | { transaction } | ||
32 | ) | ||
33 | } | ||
34 | |||
35 | async function down (utils: { | ||
36 | queryInterface: Sequelize.QueryInterface | ||
37 | transaction: Sequelize.Transaction | ||
38 | }) { | ||
39 | } | ||
40 | |||
41 | export { | ||
42 | up, | ||
43 | down | ||
44 | } | ||
diff --git a/server/initializers/migrations/0775-add-user-is-email-public.ts b/server/initializers/migrations/0775-add-user-is-email-public.ts deleted file mode 100644 index 74dee192c..000000000 --- a/server/initializers/migrations/0775-add-user-is-email-public.ts +++ /dev/null | |||
@@ -1,25 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | |||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: false, | ||
12 | defaultValue: false | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('user', 'emailPublic', data) | ||
16 | } | ||
17 | |||
18 | function down (options) { | ||
19 | throw new Error('Not implemented.') | ||
20 | } | ||
21 | |||
22 | export { | ||
23 | up, | ||
24 | down | ||
25 | } | ||
diff --git a/server/initializers/migrations/0780-notification-registration.ts b/server/initializers/migrations/0780-notification-registration.ts deleted file mode 100644 index 5f1e0d2ea..000000000 --- a/server/initializers/migrations/0780-notification-registration.ts +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | const { transaction } = utils | ||
9 | |||
10 | { | ||
11 | await utils.sequelize.query('DELETE FROM "userNotification" WHERE type = 20 AND "userRegistrationId" IS NULL', { transaction }) | ||
12 | } | ||
13 | |||
14 | { | ||
15 | await utils.sequelize.query( | ||
16 | 'ALTER TABLE "userNotification" DROP CONSTRAINT "userNotification_userRegistrationId_fkey", ' + | ||
17 | 'ADD CONSTRAINT "userNotification_userRegistrationId_fkey" ' + | ||
18 | 'FOREIGN KEY ("userRegistrationId") REFERENCES "userRegistration" ("id") ON DELETE CASCADE ON UPDATE CASCADE', | ||
19 | { transaction }) | ||
20 | } | ||
21 | } | ||
22 | |||
23 | function down (options) { | ||
24 | throw new Error('Not implemented.') | ||
25 | } | ||
26 | |||
27 | export { | ||
28 | up, | ||
29 | down | ||
30 | } | ||
diff --git a/server/initializers/migrations/0785-video-password-protection.ts b/server/initializers/migrations/0785-video-password-protection.ts deleted file mode 100644 index 1d85f4489..000000000 --- a/server/initializers/migrations/0785-video-password-protection.ts +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | { | ||
9 | const query = ` | ||
10 | CREATE TABLE IF NOT EXISTS "videoPassword" ( | ||
11 | "id" SERIAL, | ||
12 | "password" VARCHAR(255) NOT NULL, | ||
13 | "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
14 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
15 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
16 | PRIMARY KEY ("id") | ||
17 | ); | ||
18 | ` | ||
19 | |||
20 | await utils.sequelize.query(query, { transaction : utils.transaction }) | ||
21 | } | ||
22 | } | ||
23 | |||
24 | function down (options) { | ||
25 | throw new Error('Not implemented.') | ||
26 | } | ||
27 | |||
28 | export { | ||
29 | up, | ||
30 | down | ||
31 | } | ||
diff --git a/server/initializers/migrations/0790-thumbnail-disk.ts b/server/initializers/migrations/0790-thumbnail-disk.ts deleted file mode 100644 index 0824c042e..000000000 --- a/server/initializers/migrations/0790-thumbnail-disk.ts +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | const { transaction } = utils | ||
9 | |||
10 | { | ||
11 | const data = { | ||
12 | type: Sequelize.BOOLEAN, | ||
13 | allowNull: true, | ||
14 | defaultValue: true | ||
15 | } | ||
16 | |||
17 | await utils.queryInterface.addColumn('thumbnail', 'onDisk', data, { transaction }) | ||
18 | } | ||
19 | |||
20 | { | ||
21 | // Remote previews are not on the disk | ||
22 | await utils.sequelize.query( | ||
23 | 'UPDATE "thumbnail" SET "onDisk" = FALSE ' + | ||
24 | 'WHERE "type" = 2 AND "videoId" NOT IN (SELECT "id" FROM "video" WHERE "remote" IS FALSE)', | ||
25 | { transaction } | ||
26 | ) | ||
27 | } | ||
28 | |||
29 | { | ||
30 | const data = { | ||
31 | type: Sequelize.BOOLEAN, | ||
32 | allowNull: false, | ||
33 | defaultValue: null | ||
34 | } | ||
35 | |||
36 | await utils.queryInterface.changeColumn('thumbnail', 'onDisk', data, { transaction }) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | function down (options) { | ||
41 | throw new Error('Not implemented.') | ||
42 | } | ||
43 | |||
44 | export { | ||
45 | up, | ||
46 | down | ||
47 | } | ||
diff --git a/server/initializers/migrations/0795-duplicate-runner-name.ts b/server/initializers/migrations/0795-duplicate-runner-name.ts deleted file mode 100644 index dd15a8157..000000000 --- a/server/initializers/migrations/0795-duplicate-runner-name.ts +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | const { transaction } = utils | ||
9 | |||
10 | const query = 'DELETE FROM "runner" r1 ' + | ||
11 | 'USING (SELECT MIN(id) as id, "name" FROM "runner" GROUP BY "name" HAVING COUNT(*) > 1) r2 ' + | ||
12 | 'WHERE r1."name" = r2."name" AND r1.id <> r2.id' | ||
13 | |||
14 | await utils.sequelize.query(query, { transaction }) | ||
15 | } | ||
16 | |||
17 | function down (options) { | ||
18 | throw new Error('Not implemented.') | ||
19 | } | ||
20 | |||
21 | export { | ||
22 | up, | ||
23 | down | ||
24 | } | ||
diff --git a/server/initializers/migrations/0800-video-replace-file.ts b/server/initializers/migrations/0800-video-replace-file.ts deleted file mode 100644 index f924a4d92..000000000 --- a/server/initializers/migrations/0800-video-replace-file.ts +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
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 | }): Promise<void> { | ||
8 | const { transaction } = utils | ||
9 | |||
10 | { | ||
11 | const query = 'DELETE FROM "videoSource" WHERE "videoId" IS NULL' | ||
12 | await utils.sequelize.query(query, { transaction }) | ||
13 | } | ||
14 | |||
15 | { | ||
16 | const query = 'ALTER TABLE "videoSource" ALTER COLUMN "videoId" SET NOT NULL' | ||
17 | await utils.sequelize.query(query, { transaction }) | ||
18 | } | ||
19 | |||
20 | { | ||
21 | const data = { | ||
22 | type: Sequelize.DATE, | ||
23 | allowNull: true, | ||
24 | defaultValue: null | ||
25 | } | ||
26 | |||
27 | await utils.queryInterface.addColumn('video', 'inputFileUpdatedAt', data, { transaction }) | ||
28 | } | ||
29 | } | ||
30 | |||
31 | function down (options) { | ||
32 | throw new Error('Not implemented.') | ||
33 | } | ||
34 | |||
35 | export { | ||
36 | up, | ||
37 | down | ||
38 | } | ||