diff options
98 files changed, 0 insertions, 4155 deletions
diff --git a/server/initializers/migrations/0005-email-pod.ts b/server/initializers/migrations/0005-email-pod.ts deleted file mode 100644 index 025bcdb59..000000000 --- a/server/initializers/migrations/0005-email-pod.ts +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.STRING(400), | ||
13 | allowNull: false, | ||
14 | defaultValue: '' | ||
15 | } as Migration.String | ||
16 | |||
17 | return q.addColumn('Pods', 'email', data) | ||
18 | .then(() => { | ||
19 | const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\'' | ||
20 | return utils.sequelize.query(query, { transaction: utils.transaction }) | ||
21 | }) | ||
22 | .then(() => { | ||
23 | data.defaultValue = null | ||
24 | |||
25 | return q.changeColumn('Pods', 'email', data) | ||
26 | }) | ||
27 | } | ||
28 | |||
29 | function down (options) { | ||
30 | throw new Error('Not implemented.') | ||
31 | } | ||
32 | |||
33 | export { | ||
34 | up, | ||
35 | down | ||
36 | } | ||
diff --git a/server/initializers/migrations/0010-email-user.ts b/server/initializers/migrations/0010-email-user.ts deleted file mode 100644 index 4193b7ff9..000000000 --- a/server/initializers/migrations/0010-email-user.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.STRING(400), | ||
13 | allowNull: false, | ||
14 | defaultValue: '' | ||
15 | } as Migration.String | ||
16 | return q.addColumn('Users', 'email', data) | ||
17 | .then(() => { | ||
18 | const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')' | ||
19 | return utils.sequelize.query(query, { transaction: utils.transaction }) | ||
20 | }) | ||
21 | .then(() => { | ||
22 | data.defaultValue = null | ||
23 | |||
24 | return q.changeColumn('Users', 'email', 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/0015-video-views.ts b/server/initializers/migrations/0015-video-views.ts deleted file mode 100644 index aa80ffbcc..000000000 --- a/server/initializers/migrations/0015-video-views.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | const q = utils.queryInterface | ||
9 | |||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: false, | ||
13 | defaultValue: 0 | ||
14 | } | ||
15 | |||
16 | return q.addColumn('Videos', 'views', data) | ||
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/0020-video-likes.ts b/server/initializers/migrations/0020-video-likes.ts deleted file mode 100644 index aae815a8e..000000000 --- a/server/initializers/migrations/0020-video-likes.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | const q = utils.queryInterface | ||
9 | |||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: false, | ||
13 | defaultValue: 0 | ||
14 | } | ||
15 | |||
16 | return q.addColumn('Videos', 'likes', data) | ||
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/0025-video-dislikes.ts b/server/initializers/migrations/0025-video-dislikes.ts deleted file mode 100644 index 6eb6fb9dc..000000000 --- a/server/initializers/migrations/0025-video-dislikes.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | const q = utils.queryInterface | ||
9 | |||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: false, | ||
13 | defaultValue: 0 | ||
14 | } | ||
15 | |||
16 | return q.addColumn('Videos', 'dislikes', data) | ||
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/0030-video-category.ts b/server/initializers/migrations/0030-video-category.ts deleted file mode 100644 index dd3922549..000000000 --- a/server/initializers/migrations/0030-video-category.ts +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.INTEGER, | ||
13 | allowNull: false, | ||
14 | defaultValue: 0 | ||
15 | } as Migration.Integer | ||
16 | |||
17 | return q.addColumn('Videos', 'category', data) | ||
18 | .then(() => { | ||
19 | data.defaultValue = null | ||
20 | |||
21 | return q.changeColumn('Videos', 'category', data) | ||
22 | }) | ||
23 | } | ||
24 | |||
25 | function down (options) { | ||
26 | throw new Error('Not implemented.') | ||
27 | } | ||
28 | |||
29 | export { | ||
30 | up, | ||
31 | down | ||
32 | } | ||
diff --git a/server/initializers/migrations/0035-video-licence.ts b/server/initializers/migrations/0035-video-licence.ts deleted file mode 100644 index b4224d758..000000000 --- a/server/initializers/migrations/0035-video-licence.ts +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.INTEGER, | ||
13 | allowNull: false, | ||
14 | defaultValue: 0 | ||
15 | } as Migration.Integer | ||
16 | |||
17 | return q.addColumn('Videos', 'licence', data) | ||
18 | .then(() => { | ||
19 | data.defaultValue = null | ||
20 | return q.changeColumn('Videos', 'licence', data) | ||
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/0040-video-nsfw.ts b/server/initializers/migrations/0040-video-nsfw.ts deleted file mode 100644 index d5aad3e53..000000000 --- a/server/initializers/migrations/0040-video-nsfw.ts +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.BOOLEAN, | ||
13 | allowNull: false, | ||
14 | defaultValue: false | ||
15 | } as Migration.Boolean | ||
16 | |||
17 | return q.addColumn('Videos', 'nsfw', data) | ||
18 | .then(() => { | ||
19 | data.defaultValue = null | ||
20 | |||
21 | return q.changeColumn('Videos', 'nsfw', data) | ||
22 | }) | ||
23 | } | ||
24 | |||
25 | function down (options) { | ||
26 | throw new Error('Not implemented.') | ||
27 | } | ||
28 | |||
29 | export { | ||
30 | up, | ||
31 | down | ||
32 | } | ||
diff --git a/server/initializers/migrations/0045-user-display-nsfw.ts b/server/initializers/migrations/0045-user-display-nsfw.ts deleted file mode 100644 index 5226a25eb..000000000 --- a/server/initializers/migrations/0045-user-display-nsfw.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | const q = utils.queryInterface | ||
9 | |||
10 | const data = { | ||
11 | type: Sequelize.BOOLEAN, | ||
12 | allowNull: false, | ||
13 | defaultValue: false | ||
14 | } | ||
15 | |||
16 | return q.addColumn('Users', 'displayNSFW', data) | ||
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/0050-video-language.ts b/server/initializers/migrations/0050-video-language.ts deleted file mode 100644 index 0cd518272..000000000 --- a/server/initializers/migrations/0050-video-language.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | const q = utils.queryInterface | ||
9 | |||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | return q.addColumn('Videos', 'language', data) | ||
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/0055-video-uuid.ts b/server/initializers/migrations/0055-video-uuid.ts deleted file mode 100644 index 525a69ea5..000000000 --- a/server/initializers/migrations/0055-video-uuid.ts +++ /dev/null | |||
@@ -1,157 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const dataUUID = { | ||
12 | type: Sequelize.UUID, | ||
13 | defaultValue: Sequelize.UUIDV4, | ||
14 | allowNull: true | ||
15 | } as Migration.UUID | ||
16 | |||
17 | return q.addColumn('Videos', 'uuid', dataUUID) | ||
18 | .then(() => { | ||
19 | const query = 'UPDATE "Videos" SET "uuid" = "id" WHERE "remoteId" IS NULL' | ||
20 | return utils.sequelize.query(query) | ||
21 | }) | ||
22 | .then(() => { | ||
23 | const query = 'UPDATE "Videos" SET "uuid" = "remoteId" WHERE "remoteId" IS NOT NULL' | ||
24 | return utils.sequelize.query(query) | ||
25 | }) | ||
26 | .then(() => { | ||
27 | dataUUID.defaultValue = null | ||
28 | |||
29 | return q.changeColumn('Videos', 'uuid', dataUUID) | ||
30 | }) | ||
31 | .then(() => { | ||
32 | return removeForeignKey(utils.sequelize, 'RequestVideoQadus') | ||
33 | }) | ||
34 | .then(() => { | ||
35 | return removeForeignKey(utils.sequelize, 'RequestVideoEvents') | ||
36 | }) | ||
37 | .then(() => { | ||
38 | return removeForeignKey(utils.sequelize, 'BlacklistedVideos') | ||
39 | }) | ||
40 | .then(() => { | ||
41 | return removeForeignKey(utils.sequelize, 'UserVideoRates') | ||
42 | }) | ||
43 | .then(() => { | ||
44 | return removeForeignKey(utils.sequelize, 'VideoAbuses') | ||
45 | }) | ||
46 | .then(() => { | ||
47 | return removeForeignKey(utils.sequelize, 'VideoTags') | ||
48 | }) | ||
49 | .then(() => { | ||
50 | const query = 'ALTER TABLE "Videos" DROP CONSTRAINT "Videos_pkey"' | ||
51 | return utils.sequelize.query(query) | ||
52 | }) | ||
53 | .then(() => { | ||
54 | const query = 'ALTER TABLE "Videos" ADD COLUMN "id2" SERIAL PRIMARY KEY' | ||
55 | return utils.sequelize.query(query) | ||
56 | }) | ||
57 | .then(() => { | ||
58 | return q.renameColumn('Videos', 'id', 'oldId') | ||
59 | }) | ||
60 | .then(() => { | ||
61 | return q.renameColumn('Videos', 'id2', 'id') | ||
62 | }) | ||
63 | .then(() => { | ||
64 | return changeForeignKey(q, utils.sequelize, 'RequestVideoQadus', false) | ||
65 | }) | ||
66 | .then(() => { | ||
67 | return changeForeignKey(q, utils.sequelize, 'RequestVideoEvents', false) | ||
68 | }) | ||
69 | .then(() => { | ||
70 | return changeForeignKey(q, utils.sequelize, 'BlacklistedVideos', false) | ||
71 | }) | ||
72 | .then(() => { | ||
73 | return changeForeignKey(q, utils.sequelize, 'UserVideoRates', false) | ||
74 | }) | ||
75 | .then(() => { | ||
76 | return changeForeignKey(q, utils.sequelize, 'VideoAbuses', false) | ||
77 | }) | ||
78 | .then(() => { | ||
79 | return changeForeignKey(q, utils.sequelize, 'VideoTags', true) | ||
80 | }) | ||
81 | .then(() => { | ||
82 | return q.removeColumn('Videos', 'oldId') | ||
83 | }) | ||
84 | .then(() => { | ||
85 | const dataRemote = { | ||
86 | type: Sequelize.BOOLEAN, | ||
87 | defaultValue: false, | ||
88 | allowNull: false | ||
89 | } | ||
90 | return q.addColumn('Videos', 'remote', dataRemote) | ||
91 | }) | ||
92 | .then(() => { | ||
93 | const query = 'UPDATE "Videos" SET "remote" = false WHERE "remoteId" IS NULL' | ||
94 | return utils.sequelize.query(query) | ||
95 | }) | ||
96 | .then(() => { | ||
97 | const query = 'UPDATE "Videos" SET "remote" = true WHERE "remoteId" IS NOT NULL' | ||
98 | return utils.sequelize.query(query) | ||
99 | }) | ||
100 | .then(() => { | ||
101 | return q.removeColumn('Videos', 'remoteId') | ||
102 | }) | ||
103 | } | ||
104 | |||
105 | function down (options) { | ||
106 | throw new Error('Not implemented.') | ||
107 | } | ||
108 | |||
109 | function removeForeignKey (sequelize: Sequelize.Sequelize, tableName: string) { | ||
110 | const query = 'ALTER TABLE "' + tableName + '" DROP CONSTRAINT "' + tableName + '_videoId_fkey' + '"' | ||
111 | return sequelize.query(query) | ||
112 | } | ||
113 | |||
114 | function changeForeignKey (q: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, tableName: string, allowNull: boolean) { | ||
115 | const data = { | ||
116 | type: Sequelize.INTEGER, | ||
117 | allowNull: true | ||
118 | } | ||
119 | |||
120 | return q.addColumn(tableName, 'videoId2', data) | ||
121 | .then(() => { | ||
122 | const query = 'UPDATE "' + tableName + '" SET "videoId2" = ' + | ||
123 | '(SELECT "id" FROM "Videos" WHERE "' + tableName + '"."videoId" = "Videos"."oldId")' | ||
124 | return sequelize.query(query) | ||
125 | }) | ||
126 | .then(() => { | ||
127 | if (allowNull === false) { | ||
128 | data.allowNull = false | ||
129 | |||
130 | return q.changeColumn(tableName, 'videoId2', data) | ||
131 | } | ||
132 | |||
133 | return Promise.resolve() | ||
134 | }) | ||
135 | .then(() => { | ||
136 | return q.removeColumn(tableName, 'videoId') | ||
137 | }) | ||
138 | .then(() => { | ||
139 | return q.renameColumn(tableName, 'videoId2', 'videoId') | ||
140 | }) | ||
141 | .then(() => { | ||
142 | return q.addIndex(tableName, [ 'videoId' ]) | ||
143 | }) | ||
144 | .then(() => { | ||
145 | const constraintName = tableName + '_videoId_fkey' | ||
146 | const query = 'ALTER TABLE "' + tableName + '" ' + | ||
147 | ' ADD CONSTRAINT "' + constraintName + '"' + | ||
148 | ' FOREIGN KEY ("videoId") REFERENCES "Videos" ON DELETE CASCADE' | ||
149 | |||
150 | return sequelize.query(query) | ||
151 | }) | ||
152 | } | ||
153 | |||
154 | export { | ||
155 | up, | ||
156 | down | ||
157 | } | ||
diff --git a/server/initializers/migrations/0060-video-file.ts b/server/initializers/migrations/0060-video-file.ts deleted file mode 100644 index f07fa7780..000000000 --- a/server/initializers/migrations/0060-video-file.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const query = 'INSERT INTO "VideoFiles" ("videoId", "resolution", "size", "extname", "infoHash", "createdAt", "updatedAt") ' + | ||
12 | 'SELECT "id" AS "videoId", 0 AS "resolution", 0 AS "size", ' + | ||
13 | '"extname"::"text"::"enum_VideoFiles_extname" as "extname", "infoHash", "createdAt", "updatedAt" ' + | ||
14 | 'FROM "Videos"' | ||
15 | |||
16 | return utils.db.VideoFile.sync() | ||
17 | .then(() => utils.sequelize.query(query)) | ||
18 | .then(() => { | ||
19 | return q.removeColumn('Videos', 'extname') | ||
20 | }) | ||
21 | .then(() => { | ||
22 | return q.removeColumn('Videos', 'infoHash') | ||
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/0065-video-file-size.ts b/server/initializers/migrations/0065-video-file-size.ts deleted file mode 100644 index ac952a98c..000000000 --- a/server/initializers/migrations/0065-video-file-size.ts +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | throw new Error('Removed, please upgrade from a previous version first.') | ||
10 | } | ||
11 | |||
12 | function down (options) { | ||
13 | throw new Error('Not implemented.') | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | up, | ||
18 | down | ||
19 | } | ||
diff --git a/server/initializers/migrations/0070-user-video-quota.ts b/server/initializers/migrations/0070-user-video-quota.ts deleted file mode 100644 index 3fc4d2970..000000000 --- a/server/initializers/migrations/0070-user-video-quota.ts +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | 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 | const data = { | ||
13 | type: Sequelize.BIGINT, | ||
14 | allowNull: false, | ||
15 | defaultValue: -1 | ||
16 | } as Migration.BigInteger | ||
17 | |||
18 | return q.addColumn('Users', 'videoQuota', data) | ||
19 | .then(() => { | ||
20 | data.defaultValue = null | ||
21 | return q.changeColumn('Users', 'videoQuota', data) | ||
22 | }) | ||
23 | } | ||
24 | |||
25 | function down (options) { | ||
26 | throw new Error('Not implemented.') | ||
27 | } | ||
28 | |||
29 | export { | ||
30 | up, | ||
31 | down | ||
32 | } | ||
diff --git a/server/initializers/migrations/0075-video-resolutions.ts b/server/initializers/migrations/0075-video-resolutions.ts deleted file mode 100644 index 8cd47496e..000000000 --- a/server/initializers/migrations/0075-video-resolutions.ts +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | import { readdir, rename } from 'fs-extra' | ||
2 | import { join } from 'path' | ||
3 | import * as Sequelize from 'sequelize' | ||
4 | import { getVideoStreamDimensionsInfo } from '../../helpers/ffmpeg/ffprobe-utils' | ||
5 | import { CONFIG } from '../../initializers/config' | ||
6 | |||
7 | function up (utils: { | ||
8 | transaction: Sequelize.Transaction | ||
9 | queryInterface: Sequelize.QueryInterface | ||
10 | sequelize: Sequelize.Sequelize | ||
11 | db: any | ||
12 | }): Promise<void> { | ||
13 | const torrentDir = CONFIG.STORAGE.TORRENTS_DIR | ||
14 | const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR | ||
15 | |||
16 | return readdir(videoFileDir) | ||
17 | .then(videoFiles => { | ||
18 | const tasks: Promise<any>[] = [] | ||
19 | for (const videoFile of videoFiles) { | ||
20 | const matches = /^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.([a-z0-9]+)/.exec(videoFile) | ||
21 | if (matches === null) { | ||
22 | console.log('Invalid video file name %s.', videoFile) | ||
23 | continue | ||
24 | } | ||
25 | |||
26 | const uuid = matches[1] | ||
27 | const ext = matches[2] | ||
28 | |||
29 | const p = getVideoStreamDimensionsInfo(join(videoFileDir, videoFile)) | ||
30 | .then(async ({ resolution }) => { | ||
31 | const oldTorrentName = uuid + '.torrent' | ||
32 | const newTorrentName = uuid + '-' + resolution + '.torrent' | ||
33 | await rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => resolution) | ||
34 | |||
35 | const newVideoFileName = uuid + '-' + resolution + '.' + ext | ||
36 | await rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => resolution) | ||
37 | |||
38 | const query = 'UPDATE "VideoFiles" SET "resolution" = ' + resolution + | ||
39 | ' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')' | ||
40 | return utils.sequelize.query(query) | ||
41 | }) | ||
42 | |||
43 | tasks.push(p) | ||
44 | } | ||
45 | |||
46 | return Promise.all(tasks).then(() => undefined) | ||
47 | }) | ||
48 | } | ||
49 | |||
50 | function down (options) { | ||
51 | throw new Error('Not implemented.') | ||
52 | } | ||
53 | |||
54 | export { | ||
55 | up, | ||
56 | down | ||
57 | } | ||
diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts deleted file mode 100644 index ef3e15968..000000000 --- a/server/initializers/migrations/0080-video-channels.ts +++ /dev/null | |||
@@ -1,111 +0,0 @@ | |||
1 | import { buildUUID } from '@shared/extra-utils' | ||
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 | const q = utils.queryInterface | ||
11 | |||
12 | // Assert not friends | ||
13 | |||
14 | // Create uuid column for author | ||
15 | const dataAuthorUUID = { | ||
16 | type: Sequelize.UUID, | ||
17 | defaultValue: Sequelize.UUIDV4, | ||
18 | allowNull: true | ||
19 | } | ||
20 | await q.addColumn('Authors', 'uuid', dataAuthorUUID) | ||
21 | |||
22 | // Set UUID to previous authors | ||
23 | { | ||
24 | const authors = await utils.db.Author.findAll() | ||
25 | for (const author of authors) { | ||
26 | author.uuid = buildUUID() | ||
27 | await author.save() | ||
28 | } | ||
29 | } | ||
30 | |||
31 | dataAuthorUUID.allowNull = false | ||
32 | await q.changeColumn('Authors', 'uuid', dataAuthorUUID) | ||
33 | |||
34 | // Create one author per user that does not already exist | ||
35 | const users = await utils.db.User.findAll() | ||
36 | for (const user of users) { | ||
37 | const author = await utils.db.Author.find({ where: { userId: user.id } }) | ||
38 | if (!author) { | ||
39 | await utils.db.Author.create({ | ||
40 | name: user.username, | ||
41 | podId: null, // It is our pod | ||
42 | userId: user.id | ||
43 | }) | ||
44 | } | ||
45 | } | ||
46 | |||
47 | // Create video channels table | ||
48 | await utils.db.VideoChannel.sync() | ||
49 | |||
50 | // For each author, create its default video channel | ||
51 | const authors = await utils.db.Author.findAll() | ||
52 | for (const author of authors) { | ||
53 | await utils.db.VideoChannel.create({ | ||
54 | name: `Default ${author.name} channel`, | ||
55 | remote: false, | ||
56 | authorId: author.id | ||
57 | }) | ||
58 | } | ||
59 | |||
60 | // Create channelId column for videos | ||
61 | const dataChannelId = { | ||
62 | type: Sequelize.INTEGER, | ||
63 | defaultValue: null, | ||
64 | allowNull: true | ||
65 | } | ||
66 | await q.addColumn('Videos', 'channelId', dataChannelId) | ||
67 | |||
68 | const query = 'SELECT "id", "authorId" FROM "Videos"' | ||
69 | const options = { | ||
70 | type: Sequelize.QueryTypes.SELECT | ||
71 | } | ||
72 | const rawVideos = await utils.sequelize.query(query, options) as any | ||
73 | |||
74 | for (const rawVideo of rawVideos) { | ||
75 | const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } }) | ||
76 | |||
77 | const video = await utils.db.Video.findByPk(rawVideo.id) | ||
78 | video.channelId = videoChannel.id | ||
79 | await video.save() | ||
80 | } | ||
81 | |||
82 | dataChannelId.allowNull = false | ||
83 | await q.changeColumn('Videos', 'channelId', dataChannelId) | ||
84 | |||
85 | const constraintName = 'Videos_channelId_fkey' | ||
86 | const queryForeignKey = 'ALTER TABLE "Videos" ' + | ||
87 | ' ADD CONSTRAINT "' + constraintName + '"' + | ||
88 | ' FOREIGN KEY ("channelId") REFERENCES "VideoChannels" ON UPDATE CASCADE ON DELETE CASCADE' | ||
89 | |||
90 | await utils.sequelize.query(queryForeignKey) | ||
91 | |||
92 | await q.removeColumn('Videos', 'authorId') | ||
93 | } | ||
94 | |||
95 | function down (options) { | ||
96 | // update "Applications" SET "migrationVersion" = 75; | ||
97 | // delete from "Authors"; | ||
98 | // alter table "Authors" drop column "uuid"; | ||
99 | // ALTER SEQUENCE "Authors_id_seq" RESTART WITH 1 | ||
100 | // INSERT INTO "Authors" ("name", "createdAt", "updatedAt", "userId") VALUES ('root', NOW(), NOW(), 1); | ||
101 | // alter table "Videos" drop column "channelId"; | ||
102 | // drop table "VideoChannels"; | ||
103 | // alter table "Videos" add column "authorId" INTEGER DEFAULT 1; | ||
104 | // alter table "Videos" ADD CONSTRAINT "coucou" FOREIGN KEY ("authorId") REFERENCES "Authors" | ||
105 | throw new Error('Not implemented.') | ||
106 | } | ||
107 | |||
108 | export { | ||
109 | up, | ||
110 | down | ||
111 | } | ||
diff --git a/server/initializers/migrations/0085-user-role.ts b/server/initializers/migrations/0085-user-role.ts deleted file mode 100644 index ec7428fd5..000000000 --- a/server/initializers/migrations/0085-user-role.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | await q.renameColumn('Users', 'role', 'oldRole') | ||
12 | |||
13 | const data = { | ||
14 | type: Sequelize.INTEGER, | ||
15 | allowNull: true | ||
16 | } | ||
17 | await q.addColumn('Users', 'role', data) | ||
18 | |||
19 | let query = 'UPDATE "Users" SET "role" = 0 WHERE "oldRole" = \'admin\'' | ||
20 | await utils.sequelize.query(query) | ||
21 | |||
22 | query = 'UPDATE "Users" SET "role" = 2 WHERE "oldRole" = \'user\'' | ||
23 | await utils.sequelize.query(query) | ||
24 | |||
25 | data.allowNull = false | ||
26 | await q.changeColumn('Users', 'role', data) | ||
27 | |||
28 | await q.removeColumn('Users', 'oldRole') | ||
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/0090-videos-description.ts b/server/initializers/migrations/0090-videos-description.ts deleted file mode 100644 index 32e518d75..000000000 --- a/server/initializers/migrations/0090-videos-description.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | const q = utils.queryInterface | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.STRING(3000), | ||
13 | allowNull: false | ||
14 | } | ||
15 | await q.changeColumn('Videos', 'description', 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/0095-videos-privacy.ts b/server/initializers/migrations/0095-videos-privacy.ts deleted file mode 100644 index c732d6f6a..000000000 --- a/server/initializers/migrations/0095-videos-privacy.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 | const q = utils.queryInterface | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.INTEGER, | ||
13 | defaultValue: null, | ||
14 | allowNull: true | ||
15 | } | ||
16 | await q.addColumn('Videos', 'privacy', data) | ||
17 | |||
18 | const query = 'UPDATE "Videos" SET "privacy" = 1' | ||
19 | const options = { | ||
20 | type: Sequelize.QueryTypes.BULKUPDATE | ||
21 | } | ||
22 | await utils.sequelize.query(query, options) | ||
23 | |||
24 | data.allowNull = false | ||
25 | await q.changeColumn('Videos', 'privacy', data) | ||
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/0100-activitypub.ts b/server/initializers/migrations/0100-activitypub.ts deleted file mode 100644 index 49309286c..000000000 --- a/server/initializers/migrations/0100-activitypub.ts +++ /dev/null | |||
@@ -1,216 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' | ||
3 | import { shareVideoByServerAndChannel } from '../../lib/activitypub/share' | ||
4 | import { getLocalVideoActivityPubUrl, getLocalVideoChannelActivityPubUrl } from '../../lib/activitypub/url' | ||
5 | import { createLocalAccountWithoutKeys } from '../../lib/user' | ||
6 | import { ApplicationModel } from '../../models/application/application' | ||
7 | import { SERVER_ACTOR_NAME } from '../constants' | ||
8 | |||
9 | async function up (utils: { | ||
10 | transaction: Sequelize.Transaction | ||
11 | queryInterface: Sequelize.QueryInterface | ||
12 | sequelize: Sequelize.Sequelize | ||
13 | db: any | ||
14 | }): Promise<void> { | ||
15 | const q = utils.queryInterface | ||
16 | const db = utils.db | ||
17 | |||
18 | // Assert there are no friends | ||
19 | { | ||
20 | const query = 'SELECT COUNT(*) as total FROM "Pods"' | ||
21 | const options = { | ||
22 | type: Sequelize.QueryTypes.SELECT | ||
23 | } | ||
24 | const res = await utils.sequelize.query(query, options) as any | ||
25 | |||
26 | if (!res[0] || res[0].total !== 0) { | ||
27 | throw new Error('You need to quit friends.') | ||
28 | } | ||
29 | } | ||
30 | |||
31 | // Pods -> Servers | ||
32 | await utils.queryInterface.renameTable('Pods', 'Servers') | ||
33 | |||
34 | // Create Account table | ||
35 | await db.Account.sync() | ||
36 | |||
37 | // Create AccountFollows table | ||
38 | await db.AccountFollow.sync() | ||
39 | |||
40 | // Modify video abuse table | ||
41 | await db.VideoAbuse.destroy({ truncate: true }) | ||
42 | await utils.queryInterface.removeColumn('VideoAbuses', 'reporterPodId') | ||
43 | await utils.queryInterface.removeColumn('VideoAbuses', 'reporterUsername') | ||
44 | |||
45 | // Create column link with Account table | ||
46 | { | ||
47 | const data = { | ||
48 | type: Sequelize.INTEGER, | ||
49 | allowNull: false, | ||
50 | references: { | ||
51 | model: 'Accounts', | ||
52 | key: 'id' | ||
53 | }, | ||
54 | onDelete: 'CASCADE' | ||
55 | } | ||
56 | await q.addColumn('VideoAbuses', 'reporterAccountId', data) | ||
57 | } | ||
58 | |||
59 | // Drop request tables | ||
60 | await utils.queryInterface.dropTable('RequestToPods') | ||
61 | await utils.queryInterface.dropTable('RequestVideoEvents') | ||
62 | await utils.queryInterface.dropTable('RequestVideoQadus') | ||
63 | await utils.queryInterface.dropTable('Requests') | ||
64 | |||
65 | // Create application account | ||
66 | { | ||
67 | const applicationInstance = await ApplicationModel.findOne() | ||
68 | const accountCreated = await createLocalAccountWithoutKeys({ | ||
69 | name: SERVER_ACTOR_NAME, | ||
70 | userId: null, | ||
71 | applicationId: applicationInstance.id, | ||
72 | t: undefined | ||
73 | }) | ||
74 | |||
75 | const { publicKey, privateKey } = await createPrivateAndPublicKeys() | ||
76 | accountCreated.Actor.publicKey = publicKey | ||
77 | accountCreated.Actor.privateKey = privateKey | ||
78 | |||
79 | await accountCreated.save() | ||
80 | } | ||
81 | |||
82 | // Drop old video channel foreign key (referencing Authors) | ||
83 | { | ||
84 | const query = 'ALTER TABLE "VideoChannels" DROP CONSTRAINT "VideoChannels_authorId_fkey"' | ||
85 | await utils.sequelize.query(query) | ||
86 | } | ||
87 | |||
88 | // Recreate accounts for each user | ||
89 | const users = await db.User.findAll() | ||
90 | for (const user of users) { | ||
91 | const account = await createLocalAccountWithoutKeys({ name: user.username, userId: user.id, applicationId: null, t: undefined }) | ||
92 | |||
93 | const { publicKey, privateKey } = await createPrivateAndPublicKeys() | ||
94 | account.Actor.publicKey = publicKey | ||
95 | account.Actor.privateKey = privateKey | ||
96 | await account.save() | ||
97 | } | ||
98 | |||
99 | { | ||
100 | const data = { | ||
101 | type: Sequelize.INTEGER, | ||
102 | allowNull: true, | ||
103 | onDelete: 'CASCADE', | ||
104 | reference: { | ||
105 | model: 'Account', | ||
106 | key: 'id' | ||
107 | } | ||
108 | } | ||
109 | await q.addColumn('VideoChannels', 'accountId', data) | ||
110 | |||
111 | { | ||
112 | const query = 'UPDATE "VideoChannels" SET "accountId" = ' + | ||
113 | '(SELECT "Accounts"."id" FROM "Accounts" INNER JOIN "Authors" ON "Authors"."userId" = "Accounts"."userId" ' + | ||
114 | 'WHERE "VideoChannels"."authorId" = "Authors"."id")' | ||
115 | await utils.sequelize.query(query) | ||
116 | } | ||
117 | |||
118 | data.allowNull = false | ||
119 | await q.changeColumn('VideoChannels', 'accountId', data) | ||
120 | |||
121 | await q.removeColumn('VideoChannels', 'authorId') | ||
122 | } | ||
123 | |||
124 | // Add url column to "Videos" | ||
125 | { | ||
126 | const data = { | ||
127 | type: Sequelize.STRING, | ||
128 | defaultValue: null, | ||
129 | allowNull: true | ||
130 | } | ||
131 | await q.addColumn('Videos', 'url', data) | ||
132 | |||
133 | const videos = await db.Video.findAll() | ||
134 | for (const video of videos) { | ||
135 | video.url = getLocalVideoActivityPubUrl(video) | ||
136 | await video.save() | ||
137 | } | ||
138 | |||
139 | data.allowNull = false | ||
140 | await q.changeColumn('Videos', 'url', data) | ||
141 | } | ||
142 | |||
143 | // Add url column to "VideoChannels" | ||
144 | { | ||
145 | const data = { | ||
146 | type: Sequelize.STRING, | ||
147 | defaultValue: null, | ||
148 | allowNull: true | ||
149 | } | ||
150 | await q.addColumn('VideoChannels', 'url', data) | ||
151 | |||
152 | const videoChannels = await db.VideoChannel.findAll() | ||
153 | for (const videoChannel of videoChannels) { | ||
154 | videoChannel.url = getLocalVideoChannelActivityPubUrl(videoChannel) | ||
155 | await videoChannel.save() | ||
156 | } | ||
157 | |||
158 | data.allowNull = false | ||
159 | await q.changeColumn('VideoChannels', 'url', data) | ||
160 | } | ||
161 | |||
162 | // Loss old video rates, whatever | ||
163 | await utils.queryInterface.dropTable('UserVideoRates') | ||
164 | await db.AccountVideoRate.sync() | ||
165 | |||
166 | { | ||
167 | const data = { | ||
168 | type: Sequelize.ENUM('transcoding', 'activitypub-http'), | ||
169 | defaultValue: 'transcoding', | ||
170 | allowNull: false | ||
171 | } | ||
172 | await q.addColumn('Jobs', 'category', data) | ||
173 | } | ||
174 | |||
175 | await db.VideoShare.sync() | ||
176 | await db.VideoChannelShare.sync() | ||
177 | |||
178 | { | ||
179 | const videos = await db.Video.findAll({ | ||
180 | include: [ | ||
181 | { | ||
182 | model: db.Video['sequelize'].models.VideoChannel, | ||
183 | include: [ | ||
184 | { | ||
185 | model: db.Video['sequelize'].models.Account, | ||
186 | include: [ { model: db.Video['sequelize'].models.Server, required: false } ] | ||
187 | } | ||
188 | ] | ||
189 | }, | ||
190 | { | ||
191 | model: db.Video['sequelize'].models.AccountVideoRate, | ||
192 | include: [ db.Video['sequelize'].models.Account ] | ||
193 | }, | ||
194 | { | ||
195 | model: db.Video['sequelize'].models.VideoShare, | ||
196 | include: [ db.Video['sequelize'].models.Account ] | ||
197 | }, | ||
198 | db.Video['sequelize'].models.Tag, | ||
199 | db.Video['sequelize'].models.VideoFile | ||
200 | ] | ||
201 | }) | ||
202 | |||
203 | for (const video of videos) { | ||
204 | await shareVideoByServerAndChannel(video, undefined) | ||
205 | } | ||
206 | } | ||
207 | } | ||
208 | |||
209 | function down (options) { | ||
210 | throw new Error('Not implemented.') | ||
211 | } | ||
212 | |||
213 | export { | ||
214 | up, | ||
215 | down | ||
216 | } | ||
diff --git a/server/initializers/migrations/0105-server-mail.ts b/server/initializers/migrations/0105-server-mail.ts deleted file mode 100644 index 5ee37c418..000000000 --- a/server/initializers/migrations/0105-server-mail.ts +++ /dev/null | |||
@@ -1,19 +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.removeColumn('Servers', 'email') | ||
10 | } | ||
11 | |||
12 | function down (options) { | ||
13 | throw new Error('Not implemented.') | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | up, | ||
18 | down | ||
19 | } | ||
diff --git a/server/initializers/migrations/0110-server-key.ts b/server/initializers/migrations/0110-server-key.ts deleted file mode 100644 index 354cd7e76..000000000 --- a/server/initializers/migrations/0110-server-key.ts +++ /dev/null | |||
@@ -1,19 +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.removeColumn('Servers', 'publicKey') | ||
10 | } | ||
11 | |||
12 | function down (options) { | ||
13 | throw new Error('Not implemented.') | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | up, | ||
18 | down | ||
19 | } | ||
diff --git a/server/initializers/migrations/0115-account-avatar.ts b/server/initializers/migrations/0115-account-avatar.ts deleted file mode 100644 index 604b6394a..000000000 --- a/server/initializers/migrations/0115-account-avatar.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | await utils.db.Avatar.sync() | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.INTEGER, | ||
13 | allowNull: true, | ||
14 | references: { | ||
15 | model: 'Avatars', | ||
16 | key: 'id' | ||
17 | }, | ||
18 | onDelete: 'CASCADE' | ||
19 | } | ||
20 | await utils.queryInterface.addColumn('Accounts', 'avatarId', data) | ||
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/0120-video-null.ts b/server/initializers/migrations/0120-video-null.ts deleted file mode 100644 index 1b407b270..000000000 --- a/server/initializers/migrations/0120-video-null.ts +++ /dev/null | |||
@@ -1,45 +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.INTEGER, | ||
13 | allowNull: true, | ||
14 | defaultValue: null | ||
15 | } | ||
16 | await utils.queryInterface.changeColumn('Videos', 'licence', data) | ||
17 | } | ||
18 | |||
19 | { | ||
20 | const data = { | ||
21 | type: Sequelize.INTEGER, | ||
22 | allowNull: true, | ||
23 | defaultValue: null | ||
24 | } | ||
25 | await utils.queryInterface.changeColumn('Videos', 'category', data) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | const data = { | ||
30 | type: Sequelize.STRING(10000), | ||
31 | allowNull: true, | ||
32 | defaultValue: null | ||
33 | } | ||
34 | await utils.queryInterface.changeColumn('Videos', 'description', data) | ||
35 | } | ||
36 | } | ||
37 | |||
38 | function down (options) { | ||
39 | throw new Error('Not implemented.') | ||
40 | } | ||
41 | |||
42 | export { | ||
43 | up, | ||
44 | down | ||
45 | } | ||
diff --git a/server/initializers/migrations/0125-table-lowercase.ts b/server/initializers/migrations/0125-table-lowercase.ts deleted file mode 100644 index f75a56791..000000000 --- a/server/initializers/migrations/0125-table-lowercase.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 | }): Promise<void> { | ||
8 | await utils.queryInterface.renameTable('Applications', 'application') | ||
9 | await utils.queryInterface.renameTable('AccountFollows', 'accountFollow') | ||
10 | await utils.queryInterface.renameTable('AccountVideoRates', 'accountVideoRate') | ||
11 | await utils.queryInterface.renameTable('Accounts', 'account') | ||
12 | await utils.queryInterface.renameTable('Avatars', 'avatar') | ||
13 | await utils.queryInterface.renameTable('BlacklistedVideos', 'videoBlacklist') | ||
14 | await utils.queryInterface.renameTable('Jobs', 'job') | ||
15 | await utils.queryInterface.renameTable('OAuthClients', 'oAuthClient') | ||
16 | await utils.queryInterface.renameTable('OAuthTokens', 'oAuthToken') | ||
17 | await utils.queryInterface.renameTable('Servers', 'server') | ||
18 | await utils.queryInterface.renameTable('Tags', 'tag') | ||
19 | await utils.queryInterface.renameTable('Users', 'user') | ||
20 | await utils.queryInterface.renameTable('VideoAbuses', 'videoAbuse') | ||
21 | await utils.queryInterface.renameTable('VideoChannels', 'videoChannel') | ||
22 | await utils.queryInterface.renameTable('VideoChannelShares', 'videoChannelShare') | ||
23 | await utils.queryInterface.renameTable('VideoFiles', 'videoFile') | ||
24 | await utils.queryInterface.renameTable('VideoShares', 'videoShare') | ||
25 | await utils.queryInterface.renameTable('VideoTags', 'videoTag') | ||
26 | await utils.queryInterface.renameTable('Videos', 'video') | ||
27 | } | ||
28 | |||
29 | function down (options) { | ||
30 | throw new Error('Not implemented.') | ||
31 | } | ||
32 | |||
33 | export { | ||
34 | up, | ||
35 | down | ||
36 | } | ||
diff --git a/server/initializers/migrations/0130-user-autoplay-video.ts b/server/initializers/migrations/0130-user-autoplay-video.ts deleted file mode 100644 index 8f2767266..000000000 --- a/server/initializers/migrations/0130-user-autoplay-video.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | }): Promise<void> { | ||
8 | const q = utils.queryInterface | ||
9 | |||
10 | const data = { | ||
11 | type: Sequelize.BOOLEAN, | ||
12 | allowNull: false, | ||
13 | defaultValue: true | ||
14 | } | ||
15 | |||
16 | return q.addColumn('user', 'autoPlayVideo', data) | ||
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/0135-video-channel-actor.ts b/server/initializers/migrations/0135-video-channel-actor.ts deleted file mode 100644 index 6989e1cbb..000000000 --- a/server/initializers/migrations/0135-video-channel-actor.ts +++ /dev/null | |||
@@ -1,260 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { DataType } from 'sequelize-typescript' | ||
3 | import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' | ||
4 | |||
5 | async function up (utils: { | ||
6 | transaction: Sequelize.Transaction | ||
7 | queryInterface: Sequelize.QueryInterface | ||
8 | sequelize: Sequelize.Sequelize | ||
9 | }): Promise<void> { | ||
10 | // Create actor table | ||
11 | { | ||
12 | const queries = [ | ||
13 | `DROP TYPE IF EXISTS enum_actor_type`, | ||
14 | ` | ||
15 | CREATE TYPE enum_actor_type AS ENUM ( | ||
16 | 'Group', | ||
17 | 'Person', | ||
18 | 'Application' | ||
19 | ) | ||
20 | `, | ||
21 | ` | ||
22 | CREATE TABLE actor ( | ||
23 | id integer NOT NULL, | ||
24 | type enum_actor_type NOT NULL, | ||
25 | uuid uuid NOT NULL, | ||
26 | "preferredUsername" character varying(255) NOT NULL, | ||
27 | url character varying(2000) NOT NULL, | ||
28 | "publicKey" character varying(5000), | ||
29 | "privateKey" character varying(5000), | ||
30 | "followersCount" integer NOT NULL, | ||
31 | "followingCount" integer NOT NULL, | ||
32 | "inboxUrl" character varying(2000) NOT NULL, | ||
33 | "outboxUrl" character varying(2000) NOT NULL, | ||
34 | "sharedInboxUrl" character varying(2000) NOT NULL, | ||
35 | "followersUrl" character varying(2000) NOT NULL, | ||
36 | "followingUrl" character varying(2000) NOT NULL, | ||
37 | "avatarId" integer, | ||
38 | "serverId" integer, | ||
39 | "createdAt" timestamp with time zone NOT NULL, | ||
40 | "updatedAt" timestamp with time zone NOT NULL | ||
41 | );`, | ||
42 | `CREATE SEQUENCE actor_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1`, | ||
43 | `ALTER SEQUENCE actor_id_seq OWNED BY actor.id`, | ||
44 | `ALTER TABLE ONLY actor ALTER COLUMN id SET DEFAULT nextval('actor_id_seq'::regclass)`, | ||
45 | `ALTER TABLE ONLY actor ADD CONSTRAINT actor_pkey PRIMARY KEY (id);`, | ||
46 | `CREATE UNIQUE INDEX actor_preferred_username_server_id ON actor USING btree ("preferredUsername", "serverId")`, | ||
47 | `ALTER TABLE ONLY actor | ||
48 | ADD CONSTRAINT "actor_avatarId_fkey" FOREIGN KEY ("avatarId") REFERENCES avatar(id) ON UPDATE CASCADE ON DELETE CASCADE`, | ||
49 | `ALTER TABLE ONLY actor | ||
50 | ADD CONSTRAINT "actor_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES server(id) ON UPDATE CASCADE ON DELETE CASCADE;` | ||
51 | ] | ||
52 | |||
53 | for (const query of queries) { | ||
54 | await utils.sequelize.query(query) | ||
55 | } | ||
56 | } | ||
57 | |||
58 | { | ||
59 | const query1 = | ||
60 | ` | ||
61 | INSERT INTO "actor" | ||
62 | ( | ||
63 | type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", | ||
64 | "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" | ||
65 | ) | ||
66 | SELECT | ||
67 | 'Application', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", | ||
68 | "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" | ||
69 | FROM account | ||
70 | WHERE "applicationId" IS NOT NULL | ||
71 | ` | ||
72 | await utils.sequelize.query(query1) | ||
73 | |||
74 | const query2 = | ||
75 | ` | ||
76 | INSERT INTO "actor" | ||
77 | ( | ||
78 | type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", | ||
79 | "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" | ||
80 | ) | ||
81 | SELECT | ||
82 | 'Person', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", | ||
83 | "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" | ||
84 | FROM account | ||
85 | WHERE "applicationId" IS NULL | ||
86 | ` | ||
87 | await utils.sequelize.query(query2) | ||
88 | } | ||
89 | |||
90 | { | ||
91 | const data = { | ||
92 | type: DataType.INTEGER, | ||
93 | allowNull: true, | ||
94 | references: { | ||
95 | model: 'actor', | ||
96 | key: 'id' | ||
97 | }, | ||
98 | onDelete: 'CASCADE' | ||
99 | } | ||
100 | await utils.queryInterface.addColumn('account', 'actorId', data) | ||
101 | |||
102 | const query1 = `UPDATE account SET "actorId" = (SELECT id FROM actor WHERE actor.url = account.url)` | ||
103 | await utils.sequelize.query(query1) | ||
104 | |||
105 | data.allowNull = false | ||
106 | await utils.queryInterface.changeColumn('account', 'actorId', data) | ||
107 | } | ||
108 | |||
109 | { | ||
110 | const query = ` | ||
111 | INSERT INTO actor | ||
112 | ( | ||
113 | type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", | ||
114 | "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" | ||
115 | ) | ||
116 | SELECT | ||
117 | 'Group', "videoChannel".uuid, "videoChannel".uuid, "videoChannel".url, null, null, 0, 0, "videoChannel".url || '/inbox', | ||
118 | "videoChannel".url || '/outbox', "videoChannel".url || '/inbox', "videoChannel".url || '/followers', "videoChannel".url || '/following', | ||
119 | null, account."serverId", "videoChannel"."createdAt", "videoChannel"."updatedAt" | ||
120 | FROM "videoChannel" | ||
121 | INNER JOIN "account" on "videoChannel"."accountId" = "account".id | ||
122 | ` | ||
123 | await utils.sequelize.query(query) | ||
124 | } | ||
125 | |||
126 | { | ||
127 | const data = { | ||
128 | type: DataType.INTEGER, | ||
129 | allowNull: true, | ||
130 | references: { | ||
131 | model: 'actor', | ||
132 | key: 'id' | ||
133 | }, | ||
134 | onDelete: 'CASCADE' | ||
135 | } | ||
136 | await utils.queryInterface.addColumn('videoChannel', 'actorId', data) | ||
137 | |||
138 | const query1 = `UPDATE "videoChannel" SET "actorId" = (SELECT id FROM actor WHERE actor.url = "videoChannel".url)` | ||
139 | await utils.sequelize.query(query1) | ||
140 | |||
141 | data.allowNull = false | ||
142 | await utils.queryInterface.changeColumn('videoChannel', 'actorId', data) | ||
143 | } | ||
144 | |||
145 | { | ||
146 | await utils.queryInterface.renameTable('accountFollow', 'actorFollow') | ||
147 | await utils.queryInterface.renameColumn('actorFollow', 'accountId', 'actorId') | ||
148 | await utils.queryInterface.renameColumn('actorFollow', 'targetAccountId', 'targetActorId') | ||
149 | |||
150 | try { | ||
151 | await utils.queryInterface.removeConstraint('actorFollow', 'AccountFollows_accountId_fkey') | ||
152 | await utils.queryInterface.removeConstraint('actorFollow', 'AccountFollows_targetAccountId_fkey') | ||
153 | } catch { | ||
154 | await utils.queryInterface.removeConstraint('actorFollow', 'accountFollow_accountId_fkey') | ||
155 | await utils.queryInterface.removeConstraint('actorFollow', 'accountFollow_targetAccountId_fkey') | ||
156 | } | ||
157 | |||
158 | { | ||
159 | const query1 = `UPDATE "actorFollow" | ||
160 | SET "actorId" = | ||
161 | (SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."actorId")` | ||
162 | await utils.sequelize.query(query1) | ||
163 | |||
164 | const query2 = `UPDATE "actorFollow" | ||
165 | SET "targetActorId" = | ||
166 | (SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."targetActorId")` | ||
167 | |||
168 | await utils.sequelize.query(query2) | ||
169 | } | ||
170 | |||
171 | { | ||
172 | const query1 = `ALTER TABLE ONLY "actorFollow" | ||
173 | ADD CONSTRAINT "actorFollow_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;` | ||
174 | await utils.sequelize.query(query1) | ||
175 | |||
176 | const query2 = `ALTER TABLE ONLY "actorFollow" | ||
177 | ADD CONSTRAINT "actorFollow_targetActorId_fkey" FOREIGN KEY ("targetActorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;` | ||
178 | await utils.sequelize.query(query2) | ||
179 | } | ||
180 | } | ||
181 | |||
182 | { | ||
183 | await utils.queryInterface.renameColumn('videoShare', 'accountId', 'actorId') | ||
184 | |||
185 | try { | ||
186 | await utils.queryInterface.removeConstraint('videoShare', 'VideoShares_accountId_fkey') | ||
187 | } catch { | ||
188 | await utils.queryInterface.removeConstraint('videoShare', 'videoShare_accountId_fkey') | ||
189 | } | ||
190 | |||
191 | const query = `UPDATE "videoShare" | ||
192 | SET "actorId" = | ||
193 | (SELECT "actorId" FROM account WHERE id = "videoShare"."actorId")` | ||
194 | await utils.sequelize.query(query) | ||
195 | |||
196 | { | ||
197 | const query1 = `ALTER TABLE ONLY "videoShare" | ||
198 | ADD CONSTRAINT "videoShare_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;` | ||
199 | await utils.sequelize.query(query1) | ||
200 | |||
201 | const query2 = `ALTER TABLE ONLY "videoShare" | ||
202 | ADD CONSTRAINT "videoShare_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES video(id) ON UPDATE CASCADE ON DELETE CASCADE;` | ||
203 | await utils.sequelize.query(query2) | ||
204 | } | ||
205 | } | ||
206 | |||
207 | { | ||
208 | const columnsToDelete = [ | ||
209 | 'uuid', | ||
210 | 'url', | ||
211 | 'publicKey', | ||
212 | 'privateKey', | ||
213 | 'followersCount', | ||
214 | 'followingCount', | ||
215 | 'inboxUrl', | ||
216 | 'outboxUrl', | ||
217 | 'sharedInboxUrl', | ||
218 | 'followersUrl', | ||
219 | 'followingUrl', | ||
220 | 'serverId', | ||
221 | 'avatarId' | ||
222 | ] | ||
223 | for (const columnToDelete of columnsToDelete) { | ||
224 | await utils.queryInterface.removeColumn('account', columnToDelete) | ||
225 | } | ||
226 | } | ||
227 | |||
228 | { | ||
229 | const columnsToDelete = [ | ||
230 | 'uuid', | ||
231 | 'remote', | ||
232 | 'url' | ||
233 | ] | ||
234 | for (const columnToDelete of columnsToDelete) { | ||
235 | await utils.queryInterface.removeColumn('videoChannel', columnToDelete) | ||
236 | } | ||
237 | } | ||
238 | |||
239 | { | ||
240 | const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL' | ||
241 | const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT } | ||
242 | const [ res ] = await utils.sequelize.query<any>(query, options) | ||
243 | |||
244 | for (const actor of res) { | ||
245 | const { privateKey, publicKey } = await createPrivateAndPublicKeys() | ||
246 | |||
247 | const queryUpdate = `UPDATE "actor" SET "publicKey" = '${publicKey}', "privateKey" = '${privateKey}' WHERE id = ${actor.id}` | ||
248 | await utils.sequelize.query(queryUpdate) | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | |||
253 | function down (options) { | ||
254 | throw new Error('Not implemented.') | ||
255 | } | ||
256 | |||
257 | export { | ||
258 | up, | ||
259 | down | ||
260 | } | ||
diff --git a/server/initializers/migrations/0140-actor-url.ts b/server/initializers/migrations/0140-actor-url.ts deleted file mode 100644 index d790988ad..000000000 --- a/server/initializers/migrations/0140-actor-url.ts +++ /dev/null | |||
@@ -1,40 +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 | const toReplace = WEBSERVER.HOSTNAME + ':443' | ||
10 | const by = WEBSERVER.HOST | ||
11 | const replacer = column => `replace("${column}", '${toReplace}', '${by}')` | ||
12 | |||
13 | { | ||
14 | const query = `UPDATE video SET url = ${replacer('url')}` | ||
15 | await utils.sequelize.query(query) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = ` | ||
20 | UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')}, | ||
21 | "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')}, | ||
22 | "followingUrl" = ${replacer('followingUrl')} | ||
23 | ` | ||
24 | await utils.sequelize.query(query) | ||
25 | } | ||
26 | |||
27 | { | ||
28 | const query = `UPDATE server SET host = replace(host, ':443', '')` | ||
29 | await utils.sequelize.query(query) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { | ||
38 | up, | ||
39 | down | ||
40 | } | ||
diff --git a/server/initializers/migrations/0145-delete-author.ts b/server/initializers/migrations/0145-delete-author.ts deleted file mode 100644 index 6c9427997..000000000 --- a/server/initializers/migrations/0145-delete-author.ts +++ /dev/null | |||
@@ -1,18 +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.dropTable('Authors') | ||
9 | } | ||
10 | |||
11 | function down (options) { | ||
12 | throw new Error('Not implemented.') | ||
13 | } | ||
14 | |||
15 | export { | ||
16 | up, | ||
17 | down | ||
18 | } | ||
diff --git a/server/initializers/migrations/0150-avatar-cascade.ts b/server/initializers/migrations/0150-avatar-cascade.ts deleted file mode 100644 index ecf3467a0..000000000 --- a/server/initializers/migrations/0150-avatar-cascade.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 | }): Promise<void> { | ||
8 | await utils.queryInterface.removeConstraint('actor', 'actor_avatarId_fkey') | ||
9 | |||
10 | await utils.queryInterface.addConstraint('actor', { | ||
11 | fields: [ 'avatarId' ], | ||
12 | type: 'foreign key', | ||
13 | references: { | ||
14 | table: 'avatar', | ||
15 | field: 'id' | ||
16 | }, | ||
17 | onDelete: 'set null', | ||
18 | onUpdate: 'CASCADE' | ||
19 | }) | ||
20 | } | ||
21 | |||
22 | function down (options) { | ||
23 | throw new Error('Not implemented.') | ||
24 | } | ||
25 | |||
26 | export { | ||
27 | up, | ||
28 | down | ||
29 | } | ||
diff --git a/server/initializers/migrations/0155-video-comments-enabled.ts b/server/initializers/migrations/0155-video-comments-enabled.ts deleted file mode 100644 index 691640b35..000000000 --- a/server/initializers/migrations/0155-video-comments-enabled.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: false, | ||
12 | defaultValue: true | ||
13 | } as Migration.Boolean | ||
14 | await utils.queryInterface.addColumn('video', 'commentsEnabled', data) | ||
15 | |||
16 | data.defaultValue = null | ||
17 | return utils.queryInterface.changeColumn('video', 'commentsEnabled', data) | ||
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/0160-account-route.ts b/server/initializers/migrations/0160-account-route.ts deleted file mode 100644 index 97469948b..000000000 --- a/server/initializers/migrations/0160-account-route.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 | }): Promise<void> { | ||
8 | { | ||
9 | const toReplace = ':443' | ||
10 | const by = '' | ||
11 | const replacer = column => `replace("${column}", '${toReplace}', '${by}')` | ||
12 | |||
13 | const query = ` | ||
14 | UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')}, | ||
15 | "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')}, | ||
16 | "followingUrl" = ${replacer('followingUrl')} | ||
17 | ` | ||
18 | await utils.sequelize.query(query) | ||
19 | } | ||
20 | |||
21 | { | ||
22 | const toReplace = '/account/' | ||
23 | const by = '/accounts/' | ||
24 | const replacer = column => `replace("${column}", '${toReplace}', '${by}')` | ||
25 | |||
26 | const query = ` | ||
27 | UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')}, | ||
28 | "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')}, | ||
29 | "followingUrl" = ${replacer('followingUrl')} | ||
30 | ` | ||
31 | await utils.sequelize.query(query) | ||
32 | } | ||
33 | } | ||
34 | |||
35 | function down (options) { | ||
36 | throw new Error('Not implemented.') | ||
37 | } | ||
38 | |||
39 | export { | ||
40 | up, | ||
41 | down | ||
42 | } | ||
diff --git a/server/initializers/migrations/0165-video-route.ts b/server/initializers/migrations/0165-video-route.ts deleted file mode 100644 index aa7c75128..000000000 --- a/server/initializers/migrations/0165-video-route.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 toReplace = ':443' | ||
10 | const by = '' | ||
11 | const replacer = column => `replace("${column}", '${toReplace}', '${by}')` | ||
12 | |||
13 | const query = `UPDATE video SET url = ${replacer('url')}` | ||
14 | await utils.sequelize.query(query) | ||
15 | } | ||
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/0170-actor-follow-score.ts b/server/initializers/migrations/0170-actor-follow-score.ts deleted file mode 100644 index 901a3c799..000000000 --- a/server/initializers/migrations/0170-actor-follow-score.ts +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { ACTOR_FOLLOW_SCORE } from '../constants' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | await utils.queryInterface.removeColumn('server', 'score') | ||
10 | |||
11 | const data = { | ||
12 | type: Sequelize.INTEGER, | ||
13 | allowNull: false, | ||
14 | defaultValue: ACTOR_FOLLOW_SCORE.BASE | ||
15 | } | ||
16 | |||
17 | await utils.queryInterface.addColumn('actorFollow', 'score', data) | ||
18 | |||
19 | } | ||
20 | |||
21 | function down (options) { | ||
22 | throw new Error('Not implemented.') | ||
23 | } | ||
24 | |||
25 | export { | ||
26 | up, | ||
27 | down | ||
28 | } | ||
diff --git a/server/initializers/migrations/0175-actor-follow-counts.ts b/server/initializers/migrations/0175-actor-follow-counts.ts deleted file mode 100644 index d7853f8dc..000000000 --- a/server/initializers/migrations/0175-actor-follow-counts.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 | }): Promise<void> { | ||
8 | const query = 'UPDATE "actor" SET ' + | ||
9 | '"followersCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."targetActorId"), ' + | ||
10 | '"followingCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."actorId") ' + | ||
11 | 'WHERE "actor"."serverId" IS NULL' | ||
12 | |||
13 | await utils.sequelize.query(query) | ||
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/0180-job-table-delete.ts b/server/initializers/migrations/0180-job-table-delete.ts deleted file mode 100644 index fb48a0c9d..000000000 --- a/server/initializers/migrations/0180-job-table-delete.ts +++ /dev/null | |||
@@ -1,18 +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.dropTable('job') | ||
9 | } | ||
10 | |||
11 | function down (options) { | ||
12 | throw new Error('Not implemented.') | ||
13 | } | ||
14 | |||
15 | export { | ||
16 | up, | ||
17 | down | ||
18 | } | ||
diff --git a/server/initializers/migrations/0185-video-share-url.ts b/server/initializers/migrations/0185-video-share-url.ts deleted file mode 100644 index f59931e0f..000000000 --- a/server/initializers/migrations/0185-video-share-url.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 | const query = 'DELETE FROM "videoShare" s1 ' + | ||
10 | 'USING (SELECT MIN(id) as id, "actorId", "videoId" FROM "videoShare" GROUP BY "actorId", "videoId" HAVING COUNT(*) > 1) s2 ' + | ||
11 | 'WHERE s1."actorId" = s2."actorId" AND s1."videoId" = s2."videoId" AND s1.id <> s2.id' | ||
12 | await utils.sequelize.query(query) | ||
13 | } | ||
14 | |||
15 | { | ||
16 | const data = { | ||
17 | type: Sequelize.STRING, | ||
18 | allowNull: true, | ||
19 | defaultValue: null | ||
20 | } | ||
21 | await utils.queryInterface.addColumn('videoShare', 'url', data) | ||
22 | |||
23 | const query = `UPDATE "videoShare" SET "url" = (SELECT "url" FROM "video" WHERE "id" = "videoId") || '/announces/' || "actorId"` | ||
24 | await utils.sequelize.query(query) | ||
25 | |||
26 | data.allowNull = false | ||
27 | await utils.queryInterface.changeColumn('videoShare', 'url', data) | ||
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/0190-video-comment-unique-url.ts b/server/initializers/migrations/0190-video-comment-unique-url.ts deleted file mode 100644 index a8769ed41..000000000 --- a/server/initializers/migrations/0190-video-comment-unique-url.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 | }): Promise<void> { | ||
8 | { | ||
9 | const query = 'DELETE FROM "videoComment" s1 ' + | ||
10 | 'USING (SELECT MIN(id) as id, url FROM "videoComment" GROUP BY "url" HAVING COUNT(*) > 1) s2 ' + | ||
11 | 'WHERE s1."url" = s2."url" AND s1.id <> s2.id' | ||
12 | await utils.sequelize.query(query) | ||
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/0195-support.ts b/server/initializers/migrations/0195-support.ts deleted file mode 100644 index 3f7c75dce..000000000 --- a/server/initializers/migrations/0195-support.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 | }): Promise<void> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.STRING(500), | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | await utils.queryInterface.addColumn('video', 'support', data) | ||
15 | } | ||
16 | |||
17 | { | ||
18 | const data = { | ||
19 | type: Sequelize.STRING(500), | ||
20 | allowNull: true, | ||
21 | defaultValue: null | ||
22 | } | ||
23 | await utils.queryInterface.addColumn('videoChannel', 'support', data) | ||
24 | } | ||
25 | |||
26 | { | ||
27 | const data = { | ||
28 | type: Sequelize.STRING(250), | ||
29 | allowNull: true, | ||
30 | defaultValue: null | ||
31 | } | ||
32 | await utils.queryInterface.addColumn('account', 'description', data) | ||
33 | } | ||
34 | |||
35 | { | ||
36 | const data = { | ||
37 | type: Sequelize.STRING(10000), | ||
38 | allowNull: true, | ||
39 | defaultValue: null | ||
40 | } | ||
41 | await utils.queryInterface.changeColumn('video', 'description', data) | ||
42 | } | ||
43 | } | ||
44 | |||
45 | function down (options) { | ||
46 | throw new Error('Not implemented.') | ||
47 | } | ||
48 | |||
49 | export { | ||
50 | up, | ||
51 | down | ||
52 | } | ||
diff --git a/server/initializers/migrations/0200-video-published-at.ts b/server/initializers/migrations/0200-video-published-at.ts deleted file mode 100644 index d8c7b42a7..000000000 --- a/server/initializers/migrations/0200-video-published-at.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 | }): Promise<void> { | ||
8 | |||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.DATE, | ||
12 | allowNull: true, | ||
13 | defaultValue: Sequelize.NOW | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('video', 'publishedAt', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE video SET "publishedAt" = video."createdAt"' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | // Sequelize does not alter the column with NOW as default value | ||
24 | { | ||
25 | const data = { | ||
26 | type: Sequelize.DATE, | ||
27 | allowNull: false, | ||
28 | defaultValue: Sequelize.NOW | ||
29 | } | ||
30 | await utils.queryInterface.changeColumn('video', 'publishedAt', data) | ||
31 | } | ||
32 | |||
33 | } | ||
34 | |||
35 | function down (options) { | ||
36 | throw new Error('Not implemented.') | ||
37 | } | ||
38 | |||
39 | export { | ||
40 | up, | ||
41 | down | ||
42 | } | ||
diff --git a/server/initializers/migrations/0205-user-nsfw-policy.ts b/server/initializers/migrations/0205-user-nsfw-policy.ts deleted file mode 100644 index 9c2786f12..000000000 --- a/server/initializers/migrations/0205-user-nsfw-policy.ts +++ /dev/null | |||
@@ -1,46 +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 data = { | ||
11 | type: Sequelize.ENUM('do_not_list', 'blur', 'display'), | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('user', 'nsfwPolicy', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE "user" SET "nsfwPolicy" = \'do_not_list\'' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const query = 'UPDATE "user" SET "nsfwPolicy" = \'display\' WHERE "displayNSFW" = true' | ||
25 | await utils.sequelize.query(query) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | const query = 'ALTER TABLE "user" ALTER COLUMN "nsfwPolicy" SET NOT NULL' | ||
30 | await utils.sequelize.query(query) | ||
31 | } | ||
32 | |||
33 | { | ||
34 | await utils.queryInterface.removeColumn('user', 'displayNSFW') | ||
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/0210-video-language.ts b/server/initializers/migrations/0210-video-language.ts deleted file mode 100644 index ee4ce9266..000000000 --- a/server/initializers/migrations/0210-video-language.ts +++ /dev/null | |||
@@ -1,162 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { CONSTRAINTS_FIELDS } 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 | { | ||
11 | await utils.queryInterface.renameColumn('video', 'language', 'oldLanguage') | ||
12 | } | ||
13 | |||
14 | { | ||
15 | const data = { | ||
16 | type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max), | ||
17 | allowNull: true, | ||
18 | defaultValue: null | ||
19 | } | ||
20 | await utils.queryInterface.addColumn('video', 'language', data) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const languages = [ | ||
25 | { | ||
26 | oldLanguage: 1, | ||
27 | newLanguage: 'en' | ||
28 | }, | ||
29 | { | ||
30 | oldLanguage: 2, | ||
31 | newLanguage: 'es' | ||
32 | }, | ||
33 | { | ||
34 | oldLanguage: 3, | ||
35 | newLanguage: 'zh' | ||
36 | }, | ||
37 | { | ||
38 | oldLanguage: 4, | ||
39 | newLanguage: 'hi' | ||
40 | }, | ||
41 | { | ||
42 | oldLanguage: 5, | ||
43 | newLanguage: 'ar' | ||
44 | }, | ||
45 | { | ||
46 | oldLanguage: 6, | ||
47 | newLanguage: 'pt' | ||
48 | }, | ||
49 | { | ||
50 | oldLanguage: 7, | ||
51 | newLanguage: 'bn' | ||
52 | }, | ||
53 | { | ||
54 | oldLanguage: 8, | ||
55 | newLanguage: 'ru' | ||
56 | }, | ||
57 | { | ||
58 | oldLanguage: 9, | ||
59 | newLanguage: 'ja' | ||
60 | }, | ||
61 | { | ||
62 | oldLanguage: 10, | ||
63 | newLanguage: 'pa' | ||
64 | }, | ||
65 | { | ||
66 | oldLanguage: 11, | ||
67 | newLanguage: 'de' | ||
68 | }, | ||
69 | { | ||
70 | oldLanguage: 12, | ||
71 | newLanguage: 'ko' | ||
72 | }, | ||
73 | { | ||
74 | oldLanguage: 13, | ||
75 | newLanguage: 'fr' | ||
76 | }, | ||
77 | { | ||
78 | oldLanguage: 14, | ||
79 | newLanguage: 'it' | ||
80 | }, | ||
81 | { | ||
82 | oldLanguage: 1000, | ||
83 | newLanguage: 'sgn' | ||
84 | }, | ||
85 | { | ||
86 | oldLanguage: 1001, | ||
87 | newLanguage: 'ase' | ||
88 | }, | ||
89 | { | ||
90 | oldLanguage: 1002, | ||
91 | newLanguage: 'sdl' | ||
92 | }, | ||
93 | { | ||
94 | oldLanguage: 1003, | ||
95 | newLanguage: 'bfi' | ||
96 | }, | ||
97 | { | ||
98 | oldLanguage: 1004, | ||
99 | newLanguage: 'bzs' | ||
100 | }, | ||
101 | { | ||
102 | oldLanguage: 1005, | ||
103 | newLanguage: 'csl' | ||
104 | }, | ||
105 | { | ||
106 | oldLanguage: 1006, | ||
107 | newLanguage: 'cse' | ||
108 | }, | ||
109 | { | ||
110 | oldLanguage: 1007, | ||
111 | newLanguage: 'dsl' | ||
112 | }, | ||
113 | { | ||
114 | oldLanguage: 1008, | ||
115 | newLanguage: 'fsl' | ||
116 | }, | ||
117 | { | ||
118 | oldLanguage: 1009, | ||
119 | newLanguage: 'gsg' | ||
120 | }, | ||
121 | { | ||
122 | oldLanguage: 1010, | ||
123 | newLanguage: 'pks' | ||
124 | }, | ||
125 | { | ||
126 | oldLanguage: 1011, | ||
127 | newLanguage: 'jsl' | ||
128 | }, | ||
129 | { | ||
130 | oldLanguage: 1012, | ||
131 | newLanguage: 'sfs' | ||
132 | }, | ||
133 | { | ||
134 | oldLanguage: 1013, | ||
135 | newLanguage: 'swl' | ||
136 | }, | ||
137 | { | ||
138 | oldLanguage: 1014, | ||
139 | newLanguage: 'rsl' | ||
140 | } | ||
141 | ] | ||
142 | |||
143 | for (const language of languages) { | ||
144 | const query = 'UPDATE "video" SET "language" = \'' + language.newLanguage + '\' WHERE "oldLanguage" = ' + language.oldLanguage | ||
145 | await utils.sequelize.query(query) | ||
146 | } | ||
147 | } | ||
148 | |||
149 | { | ||
150 | await utils.queryInterface.removeColumn('video', 'oldLanguage') | ||
151 | } | ||
152 | |||
153 | } | ||
154 | |||
155 | function down (options) { | ||
156 | throw new Error('Not implemented.') | ||
157 | } | ||
158 | |||
159 | export { | ||
160 | up, | ||
161 | down | ||
162 | } | ||
diff --git a/server/initializers/migrations/0215-video-support-length.ts b/server/initializers/migrations/0215-video-support-length.ts deleted file mode 100644 index 26c0ca700..000000000 --- a/server/initializers/migrations/0215-video-support-length.ts +++ /dev/null | |||
@@ -1,43 +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(500), | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | await utils.queryInterface.changeColumn('video', 'support', data) | ||
15 | } | ||
16 | |||
17 | { | ||
18 | const data = { | ||
19 | type: Sequelize.STRING(500), | ||
20 | allowNull: true, | ||
21 | defaultValue: null | ||
22 | } | ||
23 | await utils.queryInterface.changeColumn('videoChannel', 'support', data) | ||
24 | } | ||
25 | |||
26 | { | ||
27 | const data = { | ||
28 | type: Sequelize.STRING(500), | ||
29 | allowNull: true, | ||
30 | defaultValue: null | ||
31 | } | ||
32 | await utils.queryInterface.changeColumn('videoChannel', 'description', data) | ||
33 | } | ||
34 | } | ||
35 | |||
36 | function down (options) { | ||
37 | throw new Error('Not implemented.') | ||
38 | } | ||
39 | |||
40 | export { | ||
41 | up, | ||
42 | down | ||
43 | } | ||
diff --git a/server/initializers/migrations/0220-video-state.ts b/server/initializers/migrations/0220-video-state.ts deleted file mode 100644 index 491702157..000000000 --- a/server/initializers/migrations/0220-video-state.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 | }): Promise<void> { | ||
8 | // waitingTranscoding column | ||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.BOOLEAN, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('video', 'waitTranscoding', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE video SET "waitTranscoding" = false' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const data = { | ||
25 | type: Sequelize.BOOLEAN, | ||
26 | allowNull: false, | ||
27 | defaultValue: null | ||
28 | } | ||
29 | await utils.queryInterface.changeColumn('video', 'waitTranscoding', data) | ||
30 | } | ||
31 | |||
32 | // state | ||
33 | { | ||
34 | const data = { | ||
35 | type: Sequelize.INTEGER, | ||
36 | allowNull: true, | ||
37 | defaultValue: null | ||
38 | } | ||
39 | await utils.queryInterface.addColumn('video', 'state', data) | ||
40 | } | ||
41 | |||
42 | { | ||
43 | // Published | ||
44 | const query = 'UPDATE video SET "state" = 1' | ||
45 | await utils.sequelize.query(query) | ||
46 | } | ||
47 | |||
48 | { | ||
49 | const data = { | ||
50 | type: Sequelize.INTEGER, | ||
51 | allowNull: false, | ||
52 | defaultValue: null | ||
53 | } | ||
54 | await utils.queryInterface.changeColumn('video', 'state', data) | ||
55 | } | ||
56 | } | ||
57 | |||
58 | function down (options) { | ||
59 | throw new Error('Not implemented.') | ||
60 | } | ||
61 | |||
62 | export { up, down } | ||
diff --git a/server/initializers/migrations/0225-video-fps.ts b/server/initializers/migrations/0225-video-fps.ts deleted file mode 100644 index 733676845..000000000 --- a/server/initializers/migrations/0225-video-fps.ts +++ /dev/null | |||
@@ -1,22 +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.INTEGER, | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | await utils.queryInterface.addColumn('videoFile', 'fps', data) | ||
15 | } | ||
16 | } | ||
17 | |||
18 | function down (options) { | ||
19 | throw new Error('Not implemented.') | ||
20 | } | ||
21 | |||
22 | export { up, down } | ||
diff --git a/server/initializers/migrations/0235-delete-some-video-indexes.ts b/server/initializers/migrations/0235-delete-some-video-indexes.ts deleted file mode 100644 index 5964b0dc5..000000000 --- a/server/initializers/migrations/0235-delete-some-video-indexes.ts +++ /dev/null | |||
@@ -1,37 +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<any> { | ||
8 | await utils.sequelize.query('DROP INDEX IF EXISTS video_id_privacy_state_wait_transcoding;') | ||
9 | await utils.sequelize.query('DROP INDEX IF EXISTS video_name;') | ||
10 | |||
11 | for (let i = 0; i < 5; i++) { | ||
12 | const query = 'DELETE FROM "videoFile" WHERE id IN ' + | ||
13 | '(SELECT id FROM (SELECT MIN(id) AS id, "videoId", "resolution", "fps" ' + | ||
14 | 'FROM "videoFile" GROUP BY "videoId", "resolution", "fps" HAVING COUNT(*) > 1) t)' | ||
15 | await utils.sequelize.query(query) | ||
16 | } | ||
17 | |||
18 | for (let i = 0; i < 5; i++) { | ||
19 | const query = 'DELETE FROM "actor" WHERE id IN ' + | ||
20 | '(SELECT id FROM (SELECT MIN(id) AS id, "uuid" ' + | ||
21 | 'FROM "actor" GROUP BY "uuid" HAVING COUNT(*) > 1) t)' | ||
22 | await utils.sequelize.query(query) | ||
23 | } | ||
24 | |||
25 | for (let i = 0; i < 5; i++) { | ||
26 | const query = 'DELETE FROM "account" WHERE id IN ' + | ||
27 | '(SELECT id FROM (SELECT MIN(id) AS id, "actorId" ' + | ||
28 | 'FROM "account" GROUP BY "actorId" HAVING COUNT(*) > 1) t)' | ||
29 | await utils.sequelize.query(query) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { up, down } | ||
diff --git a/server/initializers/migrations/0240-drop-old-indexes.ts b/server/initializers/migrations/0240-drop-old-indexes.ts deleted file mode 100644 index 39868fa2d..000000000 --- a/server/initializers/migrations/0240-drop-old-indexes.ts +++ /dev/null | |||
@@ -1,80 +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<any> { | ||
8 | |||
9 | const indexNames = [ | ||
10 | 'accounts_application_id', | ||
11 | 'accounts_user_id', | ||
12 | 'accounts_name', | ||
13 | |||
14 | 'account_video_rates_video_id_account_id', | ||
15 | 'account_video_rates_video_id_account_id_type', | ||
16 | |||
17 | 'account_follows_account_id_target_account_id', | ||
18 | 'account_follow_account_id_target_account_id', | ||
19 | 'account_follow_account_id', | ||
20 | 'account_follow_target_account_id', | ||
21 | 'account_follows_account_id', | ||
22 | 'account_follows_target_account_id', | ||
23 | |||
24 | 'o_auth_clients_client_id', | ||
25 | 'o_auth_clients_client_id_client_secret', | ||
26 | |||
27 | 'o_auth_tokens_access_token', | ||
28 | 'o_auth_tokens_refresh_token', | ||
29 | 'o_auth_tokens_o_auth_client_id', | ||
30 | 'o_auth_tokens_user_id', | ||
31 | |||
32 | 'pods_host', | ||
33 | 'servers_host', | ||
34 | |||
35 | 'tags_name', | ||
36 | |||
37 | 'users_email', | ||
38 | 'users_username', | ||
39 | |||
40 | 'videos_channel_id', | ||
41 | 'videos_created_at', | ||
42 | 'videos_duration', | ||
43 | 'videos_likes', | ||
44 | 'videos_name', | ||
45 | 'videos_uuid', | ||
46 | 'videos_views', | ||
47 | |||
48 | 'video_abuses_reporter_account_id', | ||
49 | 'video_abuses_video_id', | ||
50 | |||
51 | 'blacklisted_videos_video_id', | ||
52 | |||
53 | 'video_channels_account_id', | ||
54 | |||
55 | 'video_files_info_hash', | ||
56 | 'video_files_video_id', | ||
57 | |||
58 | 'video_shares_account_id', | ||
59 | 'video_shares_video_id', | ||
60 | |||
61 | 'video_tags_tag_id', | ||
62 | 'video_tags_video_id' | ||
63 | ] | ||
64 | |||
65 | for (const indexName of indexNames) { | ||
66 | await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";') | ||
67 | } | ||
68 | |||
69 | await utils.sequelize.query('ALTER TABLE "account" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') | ||
70 | await utils.sequelize.query('ALTER TABLE "videoChannel" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') | ||
71 | await utils.sequelize.query('ALTER TABLE "videoShare" DROP CONSTRAINT IF EXISTS "VideoShares_videoId_fkey";') | ||
72 | |||
73 | await utils.sequelize.query('DROP TABLE IF EXISTS "videoChannelShare";') | ||
74 | } | ||
75 | |||
76 | function down (options) { | ||
77 | throw new Error('Not implemented.') | ||
78 | } | ||
79 | |||
80 | export { up, down } | ||
diff --git a/server/initializers/migrations/0245-user-blocked.ts b/server/initializers/migrations/0245-user-blocked.ts deleted file mode 100644 index 19c7d5b9c..000000000 --- a/server/initializers/migrations/0245-user-blocked.ts +++ /dev/null | |||
@@ -1,45 +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<any> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | await utils.queryInterface.addColumn('user', 'blocked', data) | ||
15 | } | ||
16 | |||
17 | { | ||
18 | const query = 'UPDATE "user" SET "blocked" = false' | ||
19 | await utils.sequelize.query(query) | ||
20 | } | ||
21 | |||
22 | { | ||
23 | const data = { | ||
24 | type: Sequelize.BOOLEAN, | ||
25 | allowNull: false, | ||
26 | defaultValue: null | ||
27 | } | ||
28 | await utils.queryInterface.changeColumn('user', 'blocked', data) | ||
29 | } | ||
30 | |||
31 | { | ||
32 | const data = { | ||
33 | type: Sequelize.STRING(250), | ||
34 | allowNull: true, | ||
35 | defaultValue: null | ||
36 | } | ||
37 | await utils.queryInterface.addColumn('user', 'blockedReason', data) | ||
38 | } | ||
39 | } | ||
40 | |||
41 | function down (options) { | ||
42 | throw new Error('Not implemented.') | ||
43 | } | ||
44 | |||
45 | export { up, down } | ||
diff --git a/server/initializers/migrations/0250-video-abuse-state.ts b/server/initializers/migrations/0250-video-abuse-state.ts deleted file mode 100644 index e4993c393..000000000 --- a/server/initializers/migrations/0250-video-abuse-state.ts +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { AbuseState } from '../../../shared/models' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<any> { | ||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('videoAbuse', 'state', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE "videoAbuse" SET "state" = ' + AbuseState.PENDING | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const data = { | ||
25 | type: Sequelize.INTEGER, | ||
26 | allowNull: false, | ||
27 | defaultValue: null | ||
28 | } | ||
29 | await utils.queryInterface.changeColumn('videoAbuse', 'state', data) | ||
30 | } | ||
31 | |||
32 | { | ||
33 | const data = { | ||
34 | type: Sequelize.STRING(300), | ||
35 | allowNull: true, | ||
36 | defaultValue: null | ||
37 | } | ||
38 | await utils.queryInterface.addColumn('videoAbuse', 'moderationComment', data) | ||
39 | } | ||
40 | } | ||
41 | |||
42 | function down (options) { | ||
43 | throw new Error('Not implemented.') | ||
44 | } | ||
45 | |||
46 | export { up, down } | ||
diff --git a/server/initializers/migrations/0255-video-blacklist-reason.ts b/server/initializers/migrations/0255-video-blacklist-reason.ts deleted file mode 100644 index 7de982f93..000000000 --- a/server/initializers/migrations/0255-video-blacklist-reason.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 | }): Promise<any> { | ||
8 | |||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.STRING(300), | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('videoBlacklist', 'reason', data) | ||
16 | } | ||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { up, down } | ||
diff --git a/server/initializers/migrations/0260-upload-quota-daily.ts b/server/initializers/migrations/0260-upload-quota-daily.ts deleted file mode 100644 index cbbe391ef..000000000 --- a/server/initializers/migrations/0260-upload-quota-daily.ts +++ /dev/null | |||
@@ -1,22 +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<any> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.BIGINT, | ||
11 | allowNull: false, | ||
12 | defaultValue: -1 | ||
13 | } | ||
14 | await utils.queryInterface.addColumn('user', 'videoQuotaDaily', data) | ||
15 | } | ||
16 | } | ||
17 | |||
18 | function down (options) { | ||
19 | throw new Error('Not implemented.') | ||
20 | } | ||
21 | |||
22 | export { up, down } | ||
diff --git a/server/initializers/migrations/0265-user-email-verified.ts b/server/initializers/migrations/0265-user-email-verified.ts deleted file mode 100644 index 59dfdad2b..000000000 --- a/server/initializers/migrations/0265-user-email-verified.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<any> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('user', 'emailVerified', data) | ||
16 | } | ||
17 | |||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { up, down } | ||
diff --git a/server/initializers/migrations/0270-server-redundancy.ts b/server/initializers/migrations/0270-server-redundancy.ts deleted file mode 100644 index 903ba8a85..000000000 --- a/server/initializers/migrations/0270-server-redundancy.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<any> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: false, | ||
12 | defaultValue: false | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('server', 'redundancyAllowed', data) | ||
16 | } | ||
17 | |||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { up, down } | ||
diff --git a/server/initializers/migrations/0275-video-file-unique.ts b/server/initializers/migrations/0275-video-file-unique.ts deleted file mode 100644 index e321ecb04..000000000 --- a/server/initializers/migrations/0275-video-file-unique.ts +++ /dev/null | |||
@@ -1,40 +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<any> { | ||
8 | // Delete duplicated keys | ||
9 | { | ||
10 | const query = 'DELETE FROM "server" s1 USING "server" s2 WHERE s1.id < s2.id AND s1."host" = s2."host"' | ||
11 | await utils.sequelize.query(query) | ||
12 | } | ||
13 | |||
14 | { | ||
15 | const query = 'DELETE FROM "videoFile" vf1 USING "videoFile" vf2 WHERE vf1.id < vf2.id ' + | ||
16 | 'AND vf1."videoId" = vf2."videoId" AND vf1.resolution = vf2.resolution AND vf1.fps IS NULL' | ||
17 | await utils.sequelize.query(query) | ||
18 | } | ||
19 | |||
20 | { | ||
21 | const query = 'UPDATE "videoFile" SET fps = -1 WHERE fps IS NULL;' | ||
22 | await utils.sequelize.query(query) | ||
23 | } | ||
24 | |||
25 | { | ||
26 | const data = { | ||
27 | type: Sequelize.INTEGER, | ||
28 | allowNull: false, | ||
29 | defaultValue: -1 | ||
30 | } | ||
31 | await utils.queryInterface.changeColumn('videoFile', 'fps', data) | ||
32 | } | ||
33 | |||
34 | } | ||
35 | |||
36 | function down (options) { | ||
37 | throw new Error('Not implemented.') | ||
38 | } | ||
39 | |||
40 | export { up, down } | ||
diff --git a/server/initializers/migrations/0280-webtorrent-policy-user.ts b/server/initializers/migrations/0280-webtorrent-policy-user.ts deleted file mode 100644 index e6488356a..000000000 --- a/server/initializers/migrations/0280-webtorrent-policy-user.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 | }): Promise<any> { | ||
8 | { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: false, | ||
12 | defaultValue: true | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('user', 'webTorrentEnabled', data) | ||
16 | } | ||
17 | |||
18 | } | ||
19 | |||
20 | async function down (utils: { | ||
21 | transaction: Sequelize.Transaction | ||
22 | queryInterface: Sequelize.QueryInterface | ||
23 | sequelize: Sequelize.Sequelize | ||
24 | }): Promise<any> { | ||
25 | await utils.queryInterface.removeColumn('user', 'webTorrentEnabled') | ||
26 | } | ||
27 | |||
28 | export { up, down } | ||
diff --git a/server/initializers/migrations/0285-description-support.ts b/server/initializers/migrations/0285-description-support.ts deleted file mode 100644 index aab3a938f..000000000 --- a/server/initializers/migrations/0285-description-support.ts +++ /dev/null | |||
@@ -1,53 +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(1000), | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.changeColumn('video', 'support', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const data = { | ||
20 | type: Sequelize.STRING(1000), | ||
21 | allowNull: true, | ||
22 | defaultValue: null | ||
23 | } | ||
24 | await utils.queryInterface.changeColumn('videoChannel', 'support', data) | ||
25 | } | ||
26 | |||
27 | { | ||
28 | const data = { | ||
29 | type: Sequelize.STRING(1000), | ||
30 | allowNull: true, | ||
31 | defaultValue: null | ||
32 | } | ||
33 | await utils.queryInterface.changeColumn('videoChannel', 'description', data) | ||
34 | } | ||
35 | |||
36 | { | ||
37 | const data = { | ||
38 | type: Sequelize.STRING(1000), | ||
39 | allowNull: true, | ||
40 | defaultValue: null | ||
41 | } | ||
42 | await utils.queryInterface.changeColumn('account', 'description', data) | ||
43 | } | ||
44 | } | ||
45 | |||
46 | function down (options) { | ||
47 | throw new Error('Not implemented.') | ||
48 | } | ||
49 | |||
50 | export { | ||
51 | up, | ||
52 | down | ||
53 | } | ||
diff --git a/server/initializers/migrations/0290-account-video-rate-url.ts b/server/initializers/migrations/0290-account-video-rate-url.ts deleted file mode 100644 index b974b1a81..000000000 --- a/server/initializers/migrations/0290-account-video-rate-url.ts +++ /dev/null | |||
@@ -1,46 +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(2000), | ||
12 | allowNull: true | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('accountVideoRate', 'url', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const builtUrlQuery = `SELECT "actor"."url" || '/' || "accountVideoRate"."type" || 's/' || "videoId" ` + | ||
20 | 'FROM "accountVideoRate" ' + | ||
21 | 'INNER JOIN account ON account.id = "accountVideoRate"."accountId" ' + | ||
22 | 'INNER JOIN actor ON actor.id = account."actorId" ' + | ||
23 | 'WHERE "base".id = "accountVideoRate".id' | ||
24 | |||
25 | const query = 'UPDATE "accountVideoRate" base SET "url" = (' + builtUrlQuery + ') WHERE "url" IS NULL' | ||
26 | await utils.sequelize.query(query) | ||
27 | } | ||
28 | |||
29 | { | ||
30 | const data = { | ||
31 | type: Sequelize.STRING(2000), | ||
32 | allowNull: false, | ||
33 | defaultValue: null | ||
34 | } | ||
35 | await utils.queryInterface.changeColumn('accountVideoRate', 'url', data) | ||
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/0295-video-file-extname.ts b/server/initializers/migrations/0295-video-file-extname.ts deleted file mode 100644 index e1999b072..000000000 --- a/server/initializers/migrations/0295-video-file-extname.ts +++ /dev/null | |||
@@ -1,49 +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.renameColumn('videoFile', 'extname', 'extname_old') | ||
11 | } | ||
12 | |||
13 | { | ||
14 | const data = { | ||
15 | type: Sequelize.STRING, | ||
16 | defaultValue: null, | ||
17 | allowNull: true | ||
18 | } | ||
19 | |||
20 | await utils.queryInterface.addColumn('videoFile', 'extname', data) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const query = 'UPDATE "videoFile" SET "extname" = "extname_old"::text' | ||
25 | await utils.sequelize.query(query) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | const data = { | ||
30 | type: Sequelize.STRING, | ||
31 | defaultValue: null, | ||
32 | allowNull: false | ||
33 | } | ||
34 | await utils.queryInterface.changeColumn('videoFile', 'extname', data) | ||
35 | } | ||
36 | |||
37 | { | ||
38 | await utils.queryInterface.removeColumn('videoFile', 'extname_old') | ||
39 | } | ||
40 | } | ||
41 | |||
42 | function down (options) { | ||
43 | throw new Error('Not implemented.') | ||
44 | } | ||
45 | |||
46 | export { | ||
47 | up, | ||
48 | down | ||
49 | } | ||
diff --git a/server/initializers/migrations/0300-user-videos-history-enabled.ts b/server/initializers/migrations/0300-user-videos-history-enabled.ts deleted file mode 100644 index 5e35e14ba..000000000 --- a/server/initializers/migrations/0300-user-videos-history-enabled.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: true | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('user', 'videosHistoryEnabled', 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/0305-fix-unfederated-videos.ts b/server/initializers/migrations/0305-fix-unfederated-videos.ts deleted file mode 100644 index 9c5d56b7b..000000000 --- a/server/initializers/migrations/0305-fix-unfederated-videos.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 | { | ||
10 | const query = `INSERT INTO "videoShare" (url, "actorId", "videoId", "createdAt", "updatedAt") ` + | ||
11 | `(` + | ||
12 | `SELECT ` + | ||
13 | `video.url || '/announces/' || "videoChannel"."actorId" as url, ` + | ||
14 | `"videoChannel"."actorId" AS "actorId", ` + | ||
15 | `"video"."id" AS "videoId", ` + | ||
16 | `NOW() AS "createdAt", ` + | ||
17 | `NOW() AS "updatedAt" ` + | ||
18 | `FROM video ` + | ||
19 | `INNER JOIN "videoChannel" ON "video"."channelId" = "videoChannel"."id" ` + | ||
20 | `WHERE "video"."remote" = false AND "video"."privacy" != 3 AND "video"."state" = 1` + | ||
21 | `) ` + | ||
22 | `ON CONFLICT DO NOTHING` | ||
23 | |||
24 | await utils.sequelize.query(query) | ||
25 | } | ||
26 | |||
27 | { | ||
28 | const query = `INSERT INTO "videoShare" (url, "actorId", "videoId", "createdAt", "updatedAt") ` + | ||
29 | `(` + | ||
30 | `SELECT ` + | ||
31 | `video.url || '/announces/' || (SELECT id FROM actor WHERE "preferredUsername" = 'peertube' ORDER BY id ASC LIMIT 1) as url, ` + | ||
32 | `(SELECT id FROM actor WHERE "preferredUsername" = 'peertube' ORDER BY id ASC LIMIT 1) AS "actorId", ` + | ||
33 | `"video"."id" AS "videoId", ` + | ||
34 | `NOW() AS "createdAt", ` + | ||
35 | `NOW() AS "updatedAt" ` + | ||
36 | `FROM video ` + | ||
37 | `WHERE "video"."remote" = false AND "video"."privacy" != 3 AND "video"."state" = 1` + | ||
38 | `) ` + | ||
39 | `ON CONFLICT DO NOTHING` | ||
40 | |||
41 | await utils.sequelize.query(query) | ||
42 | } | ||
43 | } | ||
44 | |||
45 | function down (options) { | ||
46 | throw new Error('Not implemented.') | ||
47 | } | ||
48 | |||
49 | export { | ||
50 | up, | ||
51 | down | ||
52 | } | ||
diff --git a/server/initializers/migrations/0310-drop-unused-video-indexes.ts b/server/initializers/migrations/0310-drop-unused-video-indexes.ts deleted file mode 100644 index 181858d3d..000000000 --- a/server/initializers/migrations/0310-drop-unused-video-indexes.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 | const indexNames = [ | ||
10 | 'video_category', | ||
11 | 'video_licence', | ||
12 | 'video_nsfw', | ||
13 | 'video_language', | ||
14 | 'video_wait_transcoding', | ||
15 | 'video_state', | ||
16 | 'video_remote', | ||
17 | 'video_likes' | ||
18 | ] | ||
19 | |||
20 | for (const indexName of indexNames) { | ||
21 | await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";') | ||
22 | } | ||
23 | } | ||
24 | |||
25 | function down (options) { | ||
26 | throw new Error('Not implemented.') | ||
27 | } | ||
28 | |||
29 | export { | ||
30 | up, | ||
31 | down | ||
32 | } | ||
diff --git a/server/initializers/migrations/0315-user-notifications.ts b/server/initializers/migrations/0315-user-notifications.ts deleted file mode 100644 index 0e3f4fbef..000000000 --- a/server/initializers/migrations/0315-user-notifications.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 | |||
9 | { | ||
10 | const query = ` | ||
11 | CREATE TABLE IF NOT EXISTS "userNotificationSetting" ("id" SERIAL, | ||
12 | "newVideoFromSubscription" INTEGER NOT NULL DEFAULT NULL, | ||
13 | "newCommentOnMyVideo" INTEGER NOT NULL DEFAULT NULL, | ||
14 | "videoAbuseAsModerator" INTEGER NOT NULL DEFAULT NULL, | ||
15 | "blacklistOnMyVideo" INTEGER NOT NULL DEFAULT NULL, | ||
16 | "myVideoPublished" INTEGER NOT NULL DEFAULT NULL, | ||
17 | "myVideoImportFinished" INTEGER NOT NULL DEFAULT NULL, | ||
18 | "newUserRegistration" INTEGER NOT NULL DEFAULT NULL, | ||
19 | "newFollow" INTEGER NOT NULL DEFAULT NULL, | ||
20 | "commentMention" INTEGER NOT NULL DEFAULT NULL, | ||
21 | "userId" INTEGER REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
22 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
23 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
24 | PRIMARY KEY ("id")) | ||
25 | ` | ||
26 | await utils.sequelize.query(query) | ||
27 | } | ||
28 | |||
29 | { | ||
30 | const query = 'INSERT INTO "userNotificationSetting" ' + | ||
31 | '("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' + | ||
32 | '"myVideoPublished", "myVideoImportFinished", "newUserRegistration", "newFollow", "commentMention", ' + | ||
33 | '"userId", "createdAt", "updatedAt") ' + | ||
34 | '(SELECT 1, 1, 3, 3, 1, 1, 1, 1, 1, id, NOW(), NOW() FROM "user")' | ||
35 | |||
36 | await utils.sequelize.query(query) | ||
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/0320-blacklist-unfederate.ts b/server/initializers/migrations/0320-blacklist-unfederate.ts deleted file mode 100644 index 41de41c55..000000000 --- a/server/initializers/migrations/0320-blacklist-unfederate.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 | |||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.BOOLEAN, | ||
12 | allowNull: false, | ||
13 | defaultValue: false | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('videoBlacklist', 'unfederated', 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/0325-video-abuse-fields.ts b/server/initializers/migrations/0325-video-abuse-fields.ts deleted file mode 100644 index d88724a20..000000000 --- a/server/initializers/migrations/0325-video-abuse-fields.ts +++ /dev/null | |||
@@ -1,37 +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 data = { | ||
11 | type: Sequelize.STRING(3000), | ||
12 | allowNull: false, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.changeColumn('videoAbuse', 'reason', data) | ||
17 | } | ||
18 | |||
19 | { | ||
20 | const data = { | ||
21 | type: Sequelize.STRING(3000), | ||
22 | allowNull: true, | ||
23 | defaultValue: null | ||
24 | } | ||
25 | |||
26 | await utils.queryInterface.changeColumn('videoAbuse', 'moderationComment', data) | ||
27 | } | ||
28 | } | ||
29 | |||
30 | function down (options) { | ||
31 | throw new Error('Not implemented.') | ||
32 | } | ||
33 | |||
34 | export { | ||
35 | up, | ||
36 | down | ||
37 | } | ||
diff --git a/server/initializers/migrations/0330-video-streaming-playlist.ts b/server/initializers/migrations/0330-video-streaming-playlist.ts deleted file mode 100644 index f75541a7f..000000000 --- a/server/initializers/migrations/0330-video-streaming-playlist.ts +++ /dev/null | |||
@@ -1,51 +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 query = ` | ||
11 | CREATE TABLE IF NOT EXISTS "videoStreamingPlaylist" | ||
12 | ( | ||
13 | "id" SERIAL, | ||
14 | "type" INTEGER NOT NULL, | ||
15 | "playlistUrl" VARCHAR(2000) NOT NULL, | ||
16 | "p2pMediaLoaderInfohashes" VARCHAR(255)[] NOT NULL, | ||
17 | "segmentsSha256Url" VARCHAR(255) NOT NULL, | ||
18 | "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE 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 | await utils.sequelize.query(query) | ||
24 | } | ||
25 | |||
26 | { | ||
27 | const data = { | ||
28 | type: Sequelize.INTEGER, | ||
29 | allowNull: true, | ||
30 | defaultValue: null | ||
31 | } | ||
32 | |||
33 | await utils.queryInterface.changeColumn('videoRedundancy', 'videoFileId', data) | ||
34 | } | ||
35 | |||
36 | { | ||
37 | const query = 'ALTER TABLE "videoRedundancy" ADD COLUMN "videoStreamingPlaylistId" INTEGER NULL ' + | ||
38 | 'REFERENCES "videoStreamingPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE' | ||
39 | |||
40 | await utils.sequelize.query(query) | ||
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/0335-video-downloading-enabled.ts b/server/initializers/migrations/0335-video-downloading-enabled.ts deleted file mode 100644 index c745f1f02..000000000 --- a/server/initializers/migrations/0335-video-downloading-enabled.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { Migration } from '../../models/migrations' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction | ||
6 | queryInterface: Sequelize.QueryInterface | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | const data = { | ||
10 | type: Sequelize.BOOLEAN, | ||
11 | allowNull: false, | ||
12 | defaultValue: true | ||
13 | } as Migration.Boolean | ||
14 | await utils.queryInterface.addColumn('video', 'downloadEnabled', data) | ||
15 | |||
16 | data.defaultValue = null | ||
17 | return utils.queryInterface.changeColumn('video', 'downloadEnabled', data) | ||
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/0340-add-originally-published-at.ts b/server/initializers/migrations/0340-add-originally-published-at.ts deleted file mode 100644 index 7cbc14ab5..000000000 --- a/server/initializers/migrations/0340-add-originally-published-at.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.DATE, | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | await utils.queryInterface.addColumn('video', 'originallyPublishedAt', data) | ||
15 | |||
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/0345-video-playlists.ts b/server/initializers/migrations/0345-video-playlists.ts deleted file mode 100644 index 4bf3100e4..000000000 --- a/server/initializers/migrations/0345-video-playlists.ts +++ /dev/null | |||
@@ -1,88 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { buildUUID } from '@shared/extra-utils' | ||
3 | import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' | ||
4 | import { WEBSERVER } from '../constants' | ||
5 | |||
6 | async function up (utils: { | ||
7 | transaction: Sequelize.Transaction | ||
8 | queryInterface: Sequelize.QueryInterface | ||
9 | sequelize: Sequelize.Sequelize | ||
10 | }): Promise<void> { | ||
11 | const transaction = utils.transaction | ||
12 | |||
13 | { | ||
14 | const query = ` | ||
15 | CREATE TABLE IF NOT EXISTS "videoPlaylist" | ||
16 | ( | ||
17 | "id" SERIAL, | ||
18 | "name" VARCHAR(255) NOT NULL, | ||
19 | "description" VARCHAR(255), | ||
20 | "privacy" INTEGER NOT NULL, | ||
21 | "url" VARCHAR(2000) NOT NULL, | ||
22 | "uuid" UUID NOT NULL, | ||
23 | "type" INTEGER NOT NULL DEFAULT 1, | ||
24 | "ownerAccountId" INTEGER NOT NULL REFERENCES "account" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
25 | "videoChannelId" INTEGER REFERENCES "videoChannel" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
26 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
27 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
28 | PRIMARY KEY ("id") | ||
29 | );` | ||
30 | await utils.sequelize.query(query, { transaction }) | ||
31 | } | ||
32 | |||
33 | { | ||
34 | const query = ` | ||
35 | CREATE TABLE IF NOT EXISTS "videoPlaylistElement" | ||
36 | ( | ||
37 | "id" SERIAL, | ||
38 | "url" VARCHAR(2000) NOT NULL, | ||
39 | "position" INTEGER NOT NULL DEFAULT 1, | ||
40 | "startTimestamp" INTEGER, | ||
41 | "stopTimestamp" INTEGER, | ||
42 | "videoPlaylistId" INTEGER NOT NULL REFERENCES "videoPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
43 | "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
44 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
45 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
46 | PRIMARY KEY ("id") | ||
47 | );` | ||
48 | |||
49 | await utils.sequelize.query(query, { transaction }) | ||
50 | } | ||
51 | |||
52 | { | ||
53 | const userQuery = 'SELECT "username" FROM "user";' | ||
54 | |||
55 | const options = { transaction, type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT } | ||
56 | const userResult = await utils.sequelize.query<{ username: string }>(userQuery, options) | ||
57 | const usernames = userResult.map(r => r.username) | ||
58 | |||
59 | for (const username of usernames) { | ||
60 | const uuid = buildUUID() | ||
61 | |||
62 | const baseUrl = WEBSERVER.URL + '/video-playlists/' + uuid | ||
63 | const query = ` | ||
64 | INSERT INTO "videoPlaylist" ("url", "uuid", "name", "privacy", "type", "ownerAccountId", "createdAt", "updatedAt") | ||
65 | SELECT '${baseUrl}' AS "url", | ||
66 | '${uuid}' AS "uuid", | ||
67 | 'Watch later' AS "name", | ||
68 | ${VideoPlaylistPrivacy.PRIVATE} AS "privacy", | ||
69 | ${VideoPlaylistType.WATCH_LATER} AS "type", | ||
70 | "account"."id" AS "ownerAccountId", | ||
71 | NOW() as "createdAt", | ||
72 | NOW() as "updatedAt" | ||
73 | FROM "user" INNER JOIN "account" ON "user"."id" = "account"."userId" | ||
74 | WHERE "user"."username" = '${username}'` | ||
75 | |||
76 | await utils.sequelize.query(query, { transaction }) | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | function down (options) { | ||
82 | throw new Error('Not implemented.') | ||
83 | } | ||
84 | |||
85 | export { | ||
86 | up, | ||
87 | down | ||
88 | } | ||
diff --git a/server/initializers/migrations/0350-video-blacklist-type.ts b/server/initializers/migrations/0350-video-blacklist-type.ts deleted file mode 100644 index f79ae5ec7..000000000 --- a/server/initializers/migrations/0350-video-blacklist-type.ts +++ /dev/null | |||
@@ -1,64 +0,0 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { VideoBlacklistType } from '../../../shared/models/videos' | ||
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 data = { | ||
12 | type: Sequelize.INTEGER, | ||
13 | allowNull: true, | ||
14 | defaultValue: null | ||
15 | } | ||
16 | |||
17 | await utils.queryInterface.addColumn('videoBlacklist', 'type', data) | ||
18 | } | ||
19 | |||
20 | { | ||
21 | const query = 'UPDATE "videoBlacklist" SET "type" = ' + VideoBlacklistType.MANUAL | ||
22 | await utils.sequelize.query(query) | ||
23 | } | ||
24 | |||
25 | { | ||
26 | const data = { | ||
27 | type: Sequelize.INTEGER, | ||
28 | allowNull: false, | ||
29 | defaultValue: null | ||
30 | } | ||
31 | await utils.queryInterface.changeColumn('videoBlacklist', 'type', data) | ||
32 | } | ||
33 | |||
34 | { | ||
35 | const data = { | ||
36 | type: Sequelize.INTEGER, | ||
37 | defaultValue: null, | ||
38 | allowNull: true | ||
39 | } | ||
40 | await utils.queryInterface.addColumn('userNotificationSetting', 'videoAutoBlacklistAsModerator', data) | ||
41 | } | ||
42 | |||
43 | { | ||
44 | const query = 'UPDATE "userNotificationSetting" SET "videoAutoBlacklistAsModerator" = 3' | ||
45 | await utils.sequelize.query(query) | ||
46 | } | ||
47 | |||
48 | { | ||
49 | const data = { | ||
50 | type: Sequelize.INTEGER, | ||
51 | defaultValue: null, | ||
52 | allowNull: false | ||
53 | } | ||
54 | await utils.queryInterface.changeColumn('userNotificationSetting', 'videoAutoBlacklistAsModerator', data) | ||
55 | } | ||
56 | } | ||
57 | function down (options) { | ||
58 | throw new Error('Not implemented.') | ||
59 | } | ||
60 | |||
61 | export { | ||
62 | up, | ||
63 | down | ||
64 | } | ||
diff --git a/server/initializers/migrations/0355-p2p-peer-version.ts b/server/initializers/migrations/0355-p2p-peer-version.ts deleted file mode 100644 index 89af28d07..000000000 --- a/server/initializers/migrations/0355-p2p-peer-version.ts +++ /dev/null | |||
@@ -1,41 +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.INTEGER, | ||
13 | allowNull: true, | ||
14 | defaultValue: null | ||
15 | } | ||
16 | await utils.queryInterface.addColumn('videoStreamingPlaylist', 'p2pMediaLoaderPeerVersion', data) | ||
17 | } | ||
18 | |||
19 | { | ||
20 | const query = `UPDATE "videoStreamingPlaylist" SET "p2pMediaLoaderPeerVersion" = 0;` | ||
21 | await utils.sequelize.query(query) | ||
22 | } | ||
23 | |||
24 | { | ||
25 | const data = { | ||
26 | type: Sequelize.INTEGER, | ||
27 | allowNull: false, | ||
28 | defaultValue: null | ||
29 | } | ||
30 | await utils.queryInterface.changeColumn('videoStreamingPlaylist', 'p2pMediaLoaderPeerVersion', data) | ||
31 | } | ||
32 | } | ||
33 | |||
34 | function down (options) { | ||
35 | throw new Error('Not implemented.') | ||
36 | } | ||
37 | |||
38 | export { | ||
39 | up, | ||
40 | down | ||
41 | } | ||
diff --git a/server/initializers/migrations/0360-notification-instance-follower.ts b/server/initializers/migrations/0360-notification-instance-follower.ts deleted file mode 100644 index 6f9a01a9c..000000000 --- a/server/initializers/migrations/0360-notification-instance-follower.ts +++ /dev/null | |||
@@ -1,40 +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('userNotificationSetting', 'newInstanceFollower', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE "userNotificationSetting" SET "newInstanceFollower" = 1' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const data = { | ||
25 | type: Sequelize.INTEGER, | ||
26 | defaultValue: null, | ||
27 | allowNull: false | ||
28 | } | ||
29 | await utils.queryInterface.changeColumn('userNotificationSetting', 'newInstanceFollower', data) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { | ||
38 | up, | ||
39 | down | ||
40 | } | ||
diff --git a/server/initializers/migrations/0365-user-admin-flags.ts b/server/initializers/migrations/0365-user-admin-flags.ts deleted file mode 100644 index b705387da..000000000 --- a/server/initializers/migrations/0365-user-admin-flags.ts +++ /dev/null | |||
@@ -1,40 +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('user', 'adminFlags', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE "user" SET "adminFlags" = 0' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const data = { | ||
25 | type: Sequelize.INTEGER, | ||
26 | defaultValue: null, | ||
27 | allowNull: false | ||
28 | } | ||
29 | await utils.queryInterface.changeColumn('user', 'adminFlags', data) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { | ||
38 | up, | ||
39 | down | ||
40 | } | ||
diff --git a/server/initializers/migrations/0370-thumbnail.ts b/server/initializers/migrations/0370-thumbnail.ts deleted file mode 100644 index 07c25436a..000000000 --- a/server/initializers/migrations/0370-thumbnail.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 | const query = ` | ||
11 | CREATE TABLE IF NOT EXISTS "thumbnail" | ||
12 | ( | ||
13 | "id" SERIAL, | ||
14 | "filename" VARCHAR(255) NOT NULL, | ||
15 | "height" INTEGER DEFAULT NULL, | ||
16 | "width" INTEGER DEFAULT NULL, | ||
17 | "type" INTEGER NOT NULL, | ||
18 | "fileUrl" VARCHAR(255), | ||
19 | "videoId" INTEGER REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
20 | "videoPlaylistId" INTEGER REFERENCES "videoPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE, | ||
21 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
22 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
23 | PRIMARY KEY ("id") | ||
24 | );` | ||
25 | await utils.sequelize.query(query) | ||
26 | } | ||
27 | |||
28 | { | ||
29 | // All video thumbnails | ||
30 | const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' + | ||
31 | 'SELECT uuid || \'.jpg\', 1, id, 110, 200, NOW(), NOW() FROM "video"' | ||
32 | await utils.sequelize.query(query) | ||
33 | } | ||
34 | |||
35 | { | ||
36 | // All video previews | ||
37 | const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' + | ||
38 | 'SELECT uuid || \'.jpg\', 2, id, 315, 560, NOW(), NOW() FROM "video"' | ||
39 | await utils.sequelize.query(query) | ||
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/0375-account-description.ts b/server/initializers/migrations/0375-account-description.ts deleted file mode 100644 index f9af942e0..000000000 --- a/server/initializers/migrations/0375-account-description.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | const data = { | ||
10 | type: Sequelize.STRING(1000), | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.changeColumn('account', 'description', 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/0380-cleanup-timestamps.ts b/server/initializers/migrations/0380-cleanup-timestamps.ts deleted file mode 100644 index 18ecfb997..000000000 --- a/server/initializers/migrations/0380-cleanup-timestamps.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 | try { | ||
10 | await utils.queryInterface.removeColumn('application', 'createdAt') | ||
11 | } catch { /* the column could not exist */ } | ||
12 | |||
13 | try { | ||
14 | await utils.queryInterface.removeColumn('application', 'updatedAt') | ||
15 | } catch { /* the column could not exist */ } | ||
16 | |||
17 | try { | ||
18 | await utils.queryInterface.removeColumn('videoView', 'updatedAt') | ||
19 | } catch { /* the column could not exist */ } | ||
20 | } | ||
21 | |||
22 | function down (options) { | ||
23 | throw new Error('Not implemented.') | ||
24 | } | ||
25 | |||
26 | export { | ||
27 | up, | ||
28 | down | ||
29 | } | ||
diff --git a/server/initializers/migrations/0385-remove-actor-uuid.ts b/server/initializers/migrations/0385-remove-actor-uuid.ts deleted file mode 100644 index eefbc386b..000000000 --- a/server/initializers/migrations/0385-remove-actor-uuid.ts +++ /dev/null | |||
@@ -1,19 +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.removeColumn('actor', 'uuid') | ||
10 | } | ||
11 | |||
12 | function down (options) { | ||
13 | throw new Error('Not implemented.') | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | up, | ||
18 | down | ||
19 | } | ||
diff --git a/server/initializers/migrations/0390-user-pending-email.ts b/server/initializers/migrations/0390-user-pending-email.ts deleted file mode 100644 index 9cf0affa5..000000000 --- a/server/initializers/migrations/0390-user-pending-email.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | const data = { | ||
10 | type: Sequelize.STRING(400), | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('user', 'pendingEmail', 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/0395-user-video-languages.ts b/server/initializers/migrations/0395-user-video-languages.ts deleted file mode 100644 index 9c24fbc9a..000000000 --- a/server/initializers/migrations/0395-user-video-languages.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | const data = { | ||
10 | type: Sequelize.ARRAY(Sequelize.STRING), | ||
11 | allowNull: true, | ||
12 | defaultValue: null | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('user', 'videoLanguages', 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/0400-user-theme.ts b/server/initializers/migrations/0400-user-theme.ts deleted file mode 100644 index 7addb1bb3..000000000 --- a/server/initializers/migrations/0400-user-theme.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | const data = { | ||
10 | type: Sequelize.STRING, | ||
11 | allowNull: false, | ||
12 | defaultValue: 'instance-default' | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.addColumn('user', 'theme', 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/0405-plugin.ts b/server/initializers/migrations/0405-plugin.ts deleted file mode 100644 index 5c290b986..000000000 --- a/server/initializers/migrations/0405-plugin.ts +++ /dev/null | |||
@@ -1,40 +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 "plugin" | ||
12 | ( | ||
13 | "id" SERIAL, | ||
14 | "name" VARCHAR(255) NOT NULL, | ||
15 | "type" INTEGER NOT NULL, | ||
16 | "version" VARCHAR(255) NOT NULL, | ||
17 | "latestVersion" VARCHAR(255), | ||
18 | "enabled" BOOLEAN NOT NULL, | ||
19 | "uninstalled" BOOLEAN NOT NULL, | ||
20 | "peertubeEngine" VARCHAR(255) NOT NULL, | ||
21 | "description" VARCHAR(255), | ||
22 | "homepage" VARCHAR(255) NOT NULL, | ||
23 | "settings" JSONB, | ||
24 | "storage" JSONB, | ||
25 | "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
26 | "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, | ||
27 | PRIMARY KEY ("id") | ||
28 | );` | ||
29 | await utils.sequelize.query(query) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { | ||
38 | up, | ||
39 | down | ||
40 | } | ||
diff --git a/server/initializers/migrations/0410-video-playlist-element.ts b/server/initializers/migrations/0410-video-playlist-element.ts deleted file mode 100644 index be61b932b..000000000 --- a/server/initializers/migrations/0410-video-playlist-element.ts +++ /dev/null | |||
@@ -1,40 +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 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.changeColumn('videoPlaylistElement', 'videoId', data) | ||
17 | } | ||
18 | |||
19 | await utils.queryInterface.removeConstraint('videoPlaylistElement', 'videoPlaylistElement_videoId_fkey') | ||
20 | |||
21 | await utils.queryInterface.addConstraint('videoPlaylistElement', { | ||
22 | fields: [ 'videoId' ], | ||
23 | type: 'foreign key', | ||
24 | references: { | ||
25 | table: 'video', | ||
26 | field: 'id' | ||
27 | }, | ||
28 | onDelete: 'set null', | ||
29 | onUpdate: 'CASCADE' | ||
30 | }) | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { | ||
38 | up, | ||
39 | down | ||
40 | } | ||
diff --git a/server/initializers/migrations/0415-thumbnail-auto-generated.ts b/server/initializers/migrations/0415-thumbnail-auto-generated.ts deleted file mode 100644 index 98d563c88..000000000 --- a/server/initializers/migrations/0415-thumbnail-auto-generated.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.BOOLEAN, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('thumbnail', 'automaticallyGenerated', data) | ||
17 | } | ||
18 | |||
19 | { | ||
20 | // Set auto generated to true for watch later playlists | ||
21 | const query = 'UPDATE thumbnail SET "automaticallyGenerated" = true WHERE "videoPlaylistId" IN ' + | ||
22 | '(SELECT id FROM "videoPlaylist" WHERE type = 2)' | ||
23 | |||
24 | await utils.sequelize.query(query) | ||
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/0420-avatar-lazy.ts b/server/initializers/migrations/0420-avatar-lazy.ts deleted file mode 100644 index 5c74819d2..000000000 --- a/server/initializers/migrations/0420-avatar-lazy.ts +++ /dev/null | |||
@@ -1,60 +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 | // We'll add a unique index on filename, so delete duplicates or PeerTube won't start | ||
11 | const query = 'DELETE FROM "avatar" s1 ' + | ||
12 | 'USING (SELECT MIN(id) as id, filename FROM "avatar" GROUP BY "filename" HAVING COUNT(*) > 1) s2 ' + | ||
13 | 'WHERE s1."filename" = s2."filename" AND s1.id <> s2.id' | ||
14 | await utils.sequelize.query(query) | ||
15 | } | ||
16 | |||
17 | { | ||
18 | const data = { | ||
19 | type: Sequelize.STRING, | ||
20 | allowNull: true, | ||
21 | defaultValue: null | ||
22 | } | ||
23 | |||
24 | await utils.queryInterface.addColumn('avatar', 'fileUrl', data) | ||
25 | } | ||
26 | |||
27 | { | ||
28 | const data = { | ||
29 | type: Sequelize.BOOLEAN, | ||
30 | allowNull: true, | ||
31 | defaultValue: null | ||
32 | } | ||
33 | |||
34 | await utils.queryInterface.addColumn('avatar', 'onDisk', data) | ||
35 | } | ||
36 | |||
37 | { | ||
38 | const query = 'UPDATE "avatar" SET "onDisk" = true;' | ||
39 | await utils.sequelize.query(query) | ||
40 | } | ||
41 | |||
42 | { | ||
43 | const data = { | ||
44 | type: Sequelize.BOOLEAN, | ||
45 | allowNull: false, | ||
46 | defaultValue: null | ||
47 | } | ||
48 | |||
49 | await utils.queryInterface.changeColumn('avatar', 'onDisk', data) | ||
50 | } | ||
51 | } | ||
52 | |||
53 | function down (options) { | ||
54 | throw new Error('Not implemented.') | ||
55 | } | ||
56 | |||
57 | export { | ||
58 | up, | ||
59 | down | ||
60 | } | ||
diff --git a/server/initializers/migrations/0425-nullable-actor-fields.ts b/server/initializers/migrations/0425-nullable-actor-fields.ts deleted file mode 100644 index 720b99ccc..000000000 --- a/server/initializers/migrations/0425-nullable-actor-fields.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 | const data = { | ||
10 | type: Sequelize.STRING, | ||
11 | allowNull: true | ||
12 | } | ||
13 | |||
14 | await utils.queryInterface.changeColumn('actor', 'outboxUrl', data) | ||
15 | await utils.queryInterface.changeColumn('actor', 'followersUrl', data) | ||
16 | await utils.queryInterface.changeColumn('actor', 'followingUrl', data) | ||
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/0430-auto-follow-notification-setting.ts b/server/initializers/migrations/0430-auto-follow-notification-setting.ts deleted file mode 100644 index 1734828a4..000000000 --- a/server/initializers/migrations/0430-auto-follow-notification-setting.ts +++ /dev/null | |||
@@ -1,40 +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('userNotificationSetting', 'autoInstanceFollowing', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const query = 'UPDATE "userNotificationSetting" SET "autoInstanceFollowing" = 1' | ||
20 | await utils.sequelize.query(query) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const data = { | ||
25 | type: Sequelize.INTEGER, | ||
26 | defaultValue: null, | ||
27 | allowNull: false | ||
28 | } | ||
29 | await utils.queryInterface.changeColumn('userNotificationSetting', 'autoInstanceFollowing', data) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { | ||
38 | up, | ||
39 | down | ||
40 | } | ||
diff --git a/server/initializers/migrations/0435-user-modals.ts b/server/initializers/migrations/0435-user-modals.ts deleted file mode 100644 index 737440e9b..000000000 --- a/server/initializers/migrations/0435-user-modals.ts +++ /dev/null | |||
@@ -1,40 +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', 'noInstanceConfigWarningModal', data) | ||
17 | } | ||
18 | |||
19 | { | ||
20 | const data = { | ||
21 | type: Sequelize.BOOLEAN, | ||
22 | allowNull: false, | ||
23 | defaultValue: true | ||
24 | } | ||
25 | |||
26 | await utils.queryInterface.addColumn('user', 'noWelcomeModal', data) | ||
27 | data.defaultValue = false | ||
28 | |||
29 | await utils.queryInterface.changeColumn('user', 'noWelcomeModal', data) | ||
30 | } | ||
31 | } | ||
32 | |||
33 | function down (options) { | ||
34 | throw new Error('Not implemented.') | ||
35 | } | ||
36 | |||
37 | export { | ||
38 | up, | ||
39 | down | ||
40 | } | ||
diff --git a/server/initializers/migrations/0440-user-auto-play-next-video.ts b/server/initializers/migrations/0440-user-auto-play-next-video.ts deleted file mode 100644 index f3f663f59..000000000 --- a/server/initializers/migrations/0440-user-auto-play-next-video.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', 'autoPlayNextVideo', 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/0445-shared-inbox-optional.ts b/server/initializers/migrations/0445-shared-inbox-optional.ts deleted file mode 100644 index ade1a2a57..000000000 --- a/server/initializers/migrations/0445-shared-inbox-optional.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.STRING, | ||
12 | allowNull: true | ||
13 | } | ||
14 | |||
15 | await utils.queryInterface.changeColumn('actor', 'sharedInboxUrl', 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/0450-streaming-playlist-files.ts b/server/initializers/migrations/0450-streaming-playlist-files.ts deleted file mode 100644 index 08e2e3989..000000000 --- a/server/initializers/migrations/0450-streaming-playlist-files.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 | db: any | ||
8 | }): Promise<void> { | ||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: true, | ||
13 | references: { | ||
14 | model: 'videoStreamingPlaylist', | ||
15 | key: 'id' | ||
16 | }, | ||
17 | onDelete: 'CASCADE' | ||
18 | } | ||
19 | |||
20 | await utils.queryInterface.addColumn('videoFile', 'videoStreamingPlaylistId', data) | ||
21 | } | ||
22 | |||
23 | { | ||
24 | const data = { | ||
25 | type: Sequelize.INTEGER, | ||
26 | allowNull: true | ||
27 | } | ||
28 | |||
29 | await utils.queryInterface.changeColumn('videoFile', 'videoId', data) | ||
30 | } | ||
31 | |||
32 | { | ||
33 | await utils.queryInterface.removeIndex('videoFile', 'video_file_video_id_resolution_fps') | ||
34 | } | ||
35 | |||
36 | { | ||
37 | const query = 'insert into "videoFile" ' + | ||
38 | '(resolution, size, "infoHash", "videoId", "createdAt", "updatedAt", fps, extname, "videoStreamingPlaylistId")' + | ||
39 | '(SELECT "videoFile".resolution, "videoFile".size, \'fake\', NULL, "videoFile"."createdAt", "videoFile"."updatedAt", ' + | ||
40 | '"videoFile"."fps", "videoFile".extname, "videoStreamingPlaylist".id FROM "videoStreamingPlaylist" ' + | ||
41 | 'inner join video ON video.id = "videoStreamingPlaylist"."videoId" inner join "videoFile" ON "videoFile"."videoId" = video.id)' | ||
42 | |||
43 | await utils.sequelize.query(query, { transaction: utils.transaction }) | ||
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/0455-soft-delete-video-comments.ts b/server/initializers/migrations/0455-soft-delete-video-comments.ts deleted file mode 100644 index 00e56015f..000000000 --- a/server/initializers/migrations/0455-soft-delete-video-comments.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 | { | ||
10 | const data = { | ||
11 | type: Sequelize.INTEGER, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.changeColumn('videoComment', 'accountId', data) | ||
17 | } | ||
18 | |||
19 | { | ||
20 | const data = { | ||
21 | type: Sequelize.DATE, | ||
22 | allowNull: true, | ||
23 | defaultValue: null | ||
24 | } | ||
25 | await utils.queryInterface.addColumn('videoComment', 'deletedAt', data) | ||
26 | } | ||
27 | } | ||
28 | |||
29 | function down (options) { | ||
30 | throw new Error('Not implemented.') | ||
31 | } | ||
32 | |||
33 | export { | ||
34 | up, | ||
35 | down | ||
36 | } | ||
diff --git a/server/initializers/migrations/0460-user-playlist-autoplay.ts b/server/initializers/migrations/0460-user-playlist-autoplay.ts deleted file mode 100644 index d6f5081ab..000000000 --- a/server/initializers/migrations/0460-user-playlist-autoplay.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: true | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('user', 'autoPlayNextVideoPlaylist', 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/0465-thumbnail-file-url-length.ts b/server/initializers/migrations/0465-thumbnail-file-url-length.ts deleted file mode 100644 index 84a4fa0ba..000000000 --- a/server/initializers/migrations/0465-thumbnail-file-url-length.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.STRING(2000), | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.changeColumn('thumbnail', 'fileUrl', 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/0470-cleanup-indexes.ts b/server/initializers/migrations/0470-cleanup-indexes.ts deleted file mode 100644 index 7365c30f8..000000000 --- a/server/initializers/migrations/0470-cleanup-indexes.ts +++ /dev/null | |||
@@ -1,22 +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('DROP INDEX IF EXISTS video_share_account_id;') | ||
10 | await utils.sequelize.query('DROP INDEX IF EXISTS video_published_at;') | ||
11 | |||
12 | await utils.sequelize.query('ALTER TABLE "avatar" DROP COLUMN IF EXISTS "avatarId"') | ||
13 | } | ||
14 | |||
15 | function down (options) { | ||
16 | throw new Error('Not implemented.') | ||
17 | } | ||
18 | |||
19 | export { | ||
20 | up, | ||
21 | down | ||
22 | } | ||
diff --git a/server/initializers/migrations/0475-redundancy-expires-on.ts b/server/initializers/migrations/0475-redundancy-expires-on.ts deleted file mode 100644 index edbddba37..000000000 --- a/server/initializers/migrations/0475-redundancy-expires-on.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.DATE, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.changeColumn('videoRedundancy', 'expiresOn', 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/0480-caption-file-url.ts b/server/initializers/migrations/0480-caption-file-url.ts deleted file mode 100644 index 1f88206d3..000000000 --- a/server/initializers/migrations/0480-caption-file-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 data = { | ||
11 | type: Sequelize.STRING, | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('videoCaption', 'fileUrl', 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/0490-abuse-video.ts b/server/initializers/migrations/0490-abuse-video.ts deleted file mode 100644 index 610307aa4..000000000 --- a/server/initializers/migrations/0490-abuse-video.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 deletedVideo = { | ||
10 | type: Sequelize.JSONB, | ||
11 | allowNull: true | ||
12 | } | ||
13 | await utils.queryInterface.addColumn('videoAbuse', 'deletedVideo', deletedVideo) | ||
14 | await utils.sequelize.query(`ALTER TABLE "videoAbuse" ALTER COLUMN "videoId" DROP NOT NULL;`) | ||
15 | await utils.sequelize.query(`ALTER TABLE "videoAbuse" DROP CONSTRAINT IF EXISTS "videoAbuse_videoId_fkey";`) | ||
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/0495-plugin-auth.ts b/server/initializers/migrations/0495-plugin-auth.ts deleted file mode 100644 index ea636a4ad..000000000 --- a/server/initializers/migrations/0495-plugin-auth.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 | }): Promise<void> { | ||
8 | |||
9 | { | ||
10 | const password = { | ||
11 | type: Sequelize.STRING, | ||
12 | allowNull: true | ||
13 | } | ||
14 | await utils.queryInterface.changeColumn('user', 'password', password) | ||
15 | } | ||
16 | |||
17 | { | ||
18 | const pluginAuth = { | ||
19 | type: Sequelize.STRING, | ||
20 | allowNull: true | ||
21 | } | ||
22 | await utils.queryInterface.addColumn('user', 'pluginAuth', pluginAuth) | ||
23 | } | ||
24 | |||
25 | { | ||
26 | const authName = { | ||
27 | type: Sequelize.STRING, | ||
28 | allowNull: true | ||
29 | } | ||
30 | await utils.queryInterface.addColumn('oAuthToken', 'authName', authName) | ||
31 | } | ||
32 | |||
33 | } | ||
34 | |||
35 | function down (options) { | ||
36 | throw new Error('Not implemented.') | ||
37 | } | ||
38 | |||
39 | export { | ||
40 | up, | ||
41 | down | ||
42 | } | ||
diff --git a/server/initializers/migrations/0500-playlist-description-length.ts b/server/initializers/migrations/0500-playlist-description-length.ts deleted file mode 100644 index f47f3d96a..000000000 --- a/server/initializers/migrations/0500-playlist-description-length.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 description = { | ||
11 | type: Sequelize.STRING(1000), | ||
12 | allowNull: true | ||
13 | } | ||
14 | await utils.queryInterface.changeColumn('videoPlaylist', 'description', description) | ||
15 | } | ||
16 | |||
17 | } | ||
18 | |||
19 | function down (options) { | ||
20 | throw new Error('Not implemented.') | ||
21 | } | ||
22 | |||
23 | export { | ||
24 | up, | ||
25 | down | ||
26 | } | ||