From 348c2ce3ff3fe2f25a31f08bfb36c88723a0ce46 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 21 Mar 2022 14:54:29 +0100 Subject: Remove old migration files --- server/initializers/migrations/0005-email-pod.ts | 36 --- server/initializers/migrations/0010-email-user.ts | 35 --- server/initializers/migrations/0015-video-views.ts | 26 --- server/initializers/migrations/0020-video-likes.ts | 26 --- .../initializers/migrations/0025-video-dislikes.ts | 26 --- .../initializers/migrations/0030-video-category.ts | 32 --- .../initializers/migrations/0035-video-licence.ts | 31 --- server/initializers/migrations/0040-video-nsfw.ts | 32 --- .../migrations/0045-user-display-nsfw.ts | 26 --- .../initializers/migrations/0050-video-language.ts | 26 --- server/initializers/migrations/0055-video-uuid.ts | 157 ------------- server/initializers/migrations/0060-video-file.ts | 33 --- .../migrations/0065-video-file-size.ts | 19 -- .../migrations/0070-user-video-quota.ts | 32 --- .../migrations/0075-video-resolutions.ts | 57 ----- .../initializers/migrations/0080-video-channels.ts | 111 --------- server/initializers/migrations/0085-user-role.ts | 38 --- .../migrations/0090-videos-description.ts | 25 -- .../initializers/migrations/0095-videos-privacy.ts | 35 --- server/initializers/migrations/0100-activitypub.ts | 216 ----------------- server/initializers/migrations/0105-server-mail.ts | 19 -- server/initializers/migrations/0110-server-key.ts | 19 -- .../initializers/migrations/0115-account-avatar.ts | 30 --- server/initializers/migrations/0120-video-null.ts | 45 ---- .../migrations/0125-table-lowercase.ts | 36 --- .../migrations/0130-user-autoplay-video.ts | 26 --- .../migrations/0135-video-channel-actor.ts | 260 --------------------- server/initializers/migrations/0140-actor-url.ts | 40 ---- .../initializers/migrations/0145-delete-author.ts | 18 -- .../initializers/migrations/0150-avatar-cascade.ts | 29 --- .../migrations/0155-video-comments-enabled.ts | 27 --- .../initializers/migrations/0160-account-route.ts | 42 ---- server/initializers/migrations/0165-video-route.ts | 25 -- .../migrations/0170-actor-follow-score.ts | 28 --- .../migrations/0175-actor-follow-counts.ts | 23 -- .../migrations/0180-job-table-delete.ts | 18 -- .../migrations/0185-video-share-url.ts | 38 --- .../migrations/0190-video-comment-unique-url.ts | 23 -- server/initializers/migrations/0195-support.ts | 52 ----- .../migrations/0200-video-published-at.ts | 42 ---- .../migrations/0205-user-nsfw-policy.ts | 46 ---- .../initializers/migrations/0210-video-language.ts | 162 ------------- .../migrations/0215-video-support-length.ts | 43 ---- server/initializers/migrations/0220-video-state.ts | 62 ----- server/initializers/migrations/0225-video-fps.ts | 22 -- .../migrations/0235-delete-some-video-indexes.ts | 37 --- .../migrations/0240-drop-old-indexes.ts | 80 ------- .../initializers/migrations/0245-user-blocked.ts | 45 ---- .../migrations/0250-video-abuse-state.ts | 46 ---- .../migrations/0255-video-blacklist-reason.ts | 23 -- .../migrations/0260-upload-quota-daily.ts | 22 -- .../migrations/0265-user-email-verified.ts | 24 -- .../migrations/0270-server-redundancy.ts | 24 -- .../migrations/0275-video-file-unique.ts | 40 ---- .../migrations/0280-webtorrent-policy-user.ts | 28 --- .../migrations/0285-description-support.ts | 53 ----- .../migrations/0290-account-video-rate-url.ts | 46 ---- .../migrations/0295-video-file-extname.ts | 49 ---- .../migrations/0300-user-videos-history-enabled.ts | 27 --- .../migrations/0305-fix-unfederated-videos.ts | 52 ----- .../migrations/0310-drop-unused-video-indexes.ts | 32 --- .../migrations/0315-user-notifications.ts | 47 ---- .../migrations/0320-blacklist-unfederate.ts | 27 --- .../migrations/0325-video-abuse-fields.ts | 37 --- .../migrations/0330-video-streaming-playlist.ts | 51 ---- .../migrations/0335-video-downloading-enabled.ts | 27 --- .../migrations/0340-add-originally-published-at.ts | 25 -- .../migrations/0345-video-playlists.ts | 88 ------- .../migrations/0350-video-blacklist-type.ts | 64 ----- .../migrations/0355-p2p-peer-version.ts | 41 ---- .../0360-notification-instance-follower.ts | 40 ---- .../migrations/0365-user-admin-flags.ts | 40 ---- server/initializers/migrations/0370-thumbnail.ts | 50 ---- .../migrations/0375-account-description.ts | 25 -- .../migrations/0380-cleanup-timestamps.ts | 29 --- .../migrations/0385-remove-actor-uuid.ts | 19 -- .../migrations/0390-user-pending-email.ts | 25 -- .../migrations/0395-user-video-languages.ts | 25 -- server/initializers/migrations/0400-user-theme.ts | 25 -- server/initializers/migrations/0405-plugin.ts | 40 ---- .../migrations/0410-video-playlist-element.ts | 40 ---- .../migrations/0415-thumbnail-auto-generated.ts | 35 --- server/initializers/migrations/0420-avatar-lazy.ts | 60 ----- .../migrations/0425-nullable-actor-fields.ts | 26 --- .../0430-auto-follow-notification-setting.ts | 40 ---- server/initializers/migrations/0435-user-modals.ts | 40 ---- .../migrations/0440-user-auto-play-next-video.ts | 27 --- .../migrations/0445-shared-inbox-optional.ts | 26 --- .../migrations/0450-streaming-playlist-files.ts | 54 ----- .../migrations/0455-soft-delete-video-comments.ts | 36 --- .../migrations/0460-user-playlist-autoplay.ts | 27 --- .../migrations/0465-thumbnail-file-url-length.ts | 27 --- .../migrations/0470-cleanup-indexes.ts | 22 -- .../migrations/0475-redundancy-expires-on.ts | 27 --- .../migrations/0480-caption-file-url.ts | 27 --- server/initializers/migrations/0490-abuse-video.ts | 26 --- server/initializers/migrations/0495-plugin-auth.ts | 42 ---- .../migrations/0500-playlist-description-length.ts | 26 --- 98 files changed, 4155 deletions(-) delete mode 100644 server/initializers/migrations/0005-email-pod.ts delete mode 100644 server/initializers/migrations/0010-email-user.ts delete mode 100644 server/initializers/migrations/0015-video-views.ts delete mode 100644 server/initializers/migrations/0020-video-likes.ts delete mode 100644 server/initializers/migrations/0025-video-dislikes.ts delete mode 100644 server/initializers/migrations/0030-video-category.ts delete mode 100644 server/initializers/migrations/0035-video-licence.ts delete mode 100644 server/initializers/migrations/0040-video-nsfw.ts delete mode 100644 server/initializers/migrations/0045-user-display-nsfw.ts delete mode 100644 server/initializers/migrations/0050-video-language.ts delete mode 100644 server/initializers/migrations/0055-video-uuid.ts delete mode 100644 server/initializers/migrations/0060-video-file.ts delete mode 100644 server/initializers/migrations/0065-video-file-size.ts delete mode 100644 server/initializers/migrations/0070-user-video-quota.ts delete mode 100644 server/initializers/migrations/0075-video-resolutions.ts delete mode 100644 server/initializers/migrations/0080-video-channels.ts delete mode 100644 server/initializers/migrations/0085-user-role.ts delete mode 100644 server/initializers/migrations/0090-videos-description.ts delete mode 100644 server/initializers/migrations/0095-videos-privacy.ts delete mode 100644 server/initializers/migrations/0100-activitypub.ts delete mode 100644 server/initializers/migrations/0105-server-mail.ts delete mode 100644 server/initializers/migrations/0110-server-key.ts delete mode 100644 server/initializers/migrations/0115-account-avatar.ts delete mode 100644 server/initializers/migrations/0120-video-null.ts delete mode 100644 server/initializers/migrations/0125-table-lowercase.ts delete mode 100644 server/initializers/migrations/0130-user-autoplay-video.ts delete mode 100644 server/initializers/migrations/0135-video-channel-actor.ts delete mode 100644 server/initializers/migrations/0140-actor-url.ts delete mode 100644 server/initializers/migrations/0145-delete-author.ts delete mode 100644 server/initializers/migrations/0150-avatar-cascade.ts delete mode 100644 server/initializers/migrations/0155-video-comments-enabled.ts delete mode 100644 server/initializers/migrations/0160-account-route.ts delete mode 100644 server/initializers/migrations/0165-video-route.ts delete mode 100644 server/initializers/migrations/0170-actor-follow-score.ts delete mode 100644 server/initializers/migrations/0175-actor-follow-counts.ts delete mode 100644 server/initializers/migrations/0180-job-table-delete.ts delete mode 100644 server/initializers/migrations/0185-video-share-url.ts delete mode 100644 server/initializers/migrations/0190-video-comment-unique-url.ts delete mode 100644 server/initializers/migrations/0195-support.ts delete mode 100644 server/initializers/migrations/0200-video-published-at.ts delete mode 100644 server/initializers/migrations/0205-user-nsfw-policy.ts delete mode 100644 server/initializers/migrations/0210-video-language.ts delete mode 100644 server/initializers/migrations/0215-video-support-length.ts delete mode 100644 server/initializers/migrations/0220-video-state.ts delete mode 100644 server/initializers/migrations/0225-video-fps.ts delete mode 100644 server/initializers/migrations/0235-delete-some-video-indexes.ts delete mode 100644 server/initializers/migrations/0240-drop-old-indexes.ts delete mode 100644 server/initializers/migrations/0245-user-blocked.ts delete mode 100644 server/initializers/migrations/0250-video-abuse-state.ts delete mode 100644 server/initializers/migrations/0255-video-blacklist-reason.ts delete mode 100644 server/initializers/migrations/0260-upload-quota-daily.ts delete mode 100644 server/initializers/migrations/0265-user-email-verified.ts delete mode 100644 server/initializers/migrations/0270-server-redundancy.ts delete mode 100644 server/initializers/migrations/0275-video-file-unique.ts delete mode 100644 server/initializers/migrations/0280-webtorrent-policy-user.ts delete mode 100644 server/initializers/migrations/0285-description-support.ts delete mode 100644 server/initializers/migrations/0290-account-video-rate-url.ts delete mode 100644 server/initializers/migrations/0295-video-file-extname.ts delete mode 100644 server/initializers/migrations/0300-user-videos-history-enabled.ts delete mode 100644 server/initializers/migrations/0305-fix-unfederated-videos.ts delete mode 100644 server/initializers/migrations/0310-drop-unused-video-indexes.ts delete mode 100644 server/initializers/migrations/0315-user-notifications.ts delete mode 100644 server/initializers/migrations/0320-blacklist-unfederate.ts delete mode 100644 server/initializers/migrations/0325-video-abuse-fields.ts delete mode 100644 server/initializers/migrations/0330-video-streaming-playlist.ts delete mode 100644 server/initializers/migrations/0335-video-downloading-enabled.ts delete mode 100644 server/initializers/migrations/0340-add-originally-published-at.ts delete mode 100644 server/initializers/migrations/0345-video-playlists.ts delete mode 100644 server/initializers/migrations/0350-video-blacklist-type.ts delete mode 100644 server/initializers/migrations/0355-p2p-peer-version.ts delete mode 100644 server/initializers/migrations/0360-notification-instance-follower.ts delete mode 100644 server/initializers/migrations/0365-user-admin-flags.ts delete mode 100644 server/initializers/migrations/0370-thumbnail.ts delete mode 100644 server/initializers/migrations/0375-account-description.ts delete mode 100644 server/initializers/migrations/0380-cleanup-timestamps.ts delete mode 100644 server/initializers/migrations/0385-remove-actor-uuid.ts delete mode 100644 server/initializers/migrations/0390-user-pending-email.ts delete mode 100644 server/initializers/migrations/0395-user-video-languages.ts delete mode 100644 server/initializers/migrations/0400-user-theme.ts delete mode 100644 server/initializers/migrations/0405-plugin.ts delete mode 100644 server/initializers/migrations/0410-video-playlist-element.ts delete mode 100644 server/initializers/migrations/0415-thumbnail-auto-generated.ts delete mode 100644 server/initializers/migrations/0420-avatar-lazy.ts delete mode 100644 server/initializers/migrations/0425-nullable-actor-fields.ts delete mode 100644 server/initializers/migrations/0430-auto-follow-notification-setting.ts delete mode 100644 server/initializers/migrations/0435-user-modals.ts delete mode 100644 server/initializers/migrations/0440-user-auto-play-next-video.ts delete mode 100644 server/initializers/migrations/0445-shared-inbox-optional.ts delete mode 100644 server/initializers/migrations/0450-streaming-playlist-files.ts delete mode 100644 server/initializers/migrations/0455-soft-delete-video-comments.ts delete mode 100644 server/initializers/migrations/0460-user-playlist-autoplay.ts delete mode 100644 server/initializers/migrations/0465-thumbnail-file-url-length.ts delete mode 100644 server/initializers/migrations/0470-cleanup-indexes.ts delete mode 100644 server/initializers/migrations/0475-redundancy-expires-on.ts delete mode 100644 server/initializers/migrations/0480-caption-file-url.ts delete mode 100644 server/initializers/migrations/0490-abuse-video.ts delete mode 100644 server/initializers/migrations/0495-plugin-auth.ts delete mode 100644 server/initializers/migrations/0500-playlist-description-length.ts (limited to 'server') 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.STRING(400), - allowNull: false, - defaultValue: '' - } as Migration.String - - return q.addColumn('Pods', 'email', data) - .then(() => { - const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\'' - return utils.sequelize.query(query, { transaction: utils.transaction }) - }) - .then(() => { - data.defaultValue = null - - return q.changeColumn('Pods', 'email', data) - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.STRING(400), - allowNull: false, - defaultValue: '' - } as Migration.String - return q.addColumn('Users', 'email', data) - .then(() => { - const query = 'UPDATE "Users" SET "email" = CONCAT("username", \'@example.com\')' - return utils.sequelize.query(query, { transaction: utils.transaction }) - }) - .then(() => { - data.defaultValue = null - - return q.changeColumn('Users', 'email', data) - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: 0 - } - - return q.addColumn('Videos', 'views', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: 0 - } - - return q.addColumn('Videos', 'likes', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: 0 - } - - return q.addColumn('Videos', 'dislikes', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: 0 - } as Migration.Integer - - return q.addColumn('Videos', 'category', data) - .then(() => { - data.defaultValue = null - - return q.changeColumn('Videos', 'category', data) - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: 0 - } as Migration.Integer - - return q.addColumn('Videos', 'licence', data) - .then(() => { - data.defaultValue = null - return q.changeColumn('Videos', 'licence', data) - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - } as Migration.Boolean - - return q.addColumn('Videos', 'nsfw', data) - .then(() => { - data.defaultValue = null - - return q.changeColumn('Videos', 'nsfw', data) - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - } - - return q.addColumn('Users', 'displayNSFW', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - - return q.addColumn('Videos', 'language', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const dataUUID = { - type: Sequelize.UUID, - defaultValue: Sequelize.UUIDV4, - allowNull: true - } as Migration.UUID - - return q.addColumn('Videos', 'uuid', dataUUID) - .then(() => { - const query = 'UPDATE "Videos" SET "uuid" = "id" WHERE "remoteId" IS NULL' - return utils.sequelize.query(query) - }) - .then(() => { - const query = 'UPDATE "Videos" SET "uuid" = "remoteId" WHERE "remoteId" IS NOT NULL' - return utils.sequelize.query(query) - }) - .then(() => { - dataUUID.defaultValue = null - - return q.changeColumn('Videos', 'uuid', dataUUID) - }) - .then(() => { - return removeForeignKey(utils.sequelize, 'RequestVideoQadus') - }) - .then(() => { - return removeForeignKey(utils.sequelize, 'RequestVideoEvents') - }) - .then(() => { - return removeForeignKey(utils.sequelize, 'BlacklistedVideos') - }) - .then(() => { - return removeForeignKey(utils.sequelize, 'UserVideoRates') - }) - .then(() => { - return removeForeignKey(utils.sequelize, 'VideoAbuses') - }) - .then(() => { - return removeForeignKey(utils.sequelize, 'VideoTags') - }) - .then(() => { - const query = 'ALTER TABLE "Videos" DROP CONSTRAINT "Videos_pkey"' - return utils.sequelize.query(query) - }) - .then(() => { - const query = 'ALTER TABLE "Videos" ADD COLUMN "id2" SERIAL PRIMARY KEY' - return utils.sequelize.query(query) - }) - .then(() => { - return q.renameColumn('Videos', 'id', 'oldId') - }) - .then(() => { - return q.renameColumn('Videos', 'id2', 'id') - }) - .then(() => { - return changeForeignKey(q, utils.sequelize, 'RequestVideoQadus', false) - }) - .then(() => { - return changeForeignKey(q, utils.sequelize, 'RequestVideoEvents', false) - }) - .then(() => { - return changeForeignKey(q, utils.sequelize, 'BlacklistedVideos', false) - }) - .then(() => { - return changeForeignKey(q, utils.sequelize, 'UserVideoRates', false) - }) - .then(() => { - return changeForeignKey(q, utils.sequelize, 'VideoAbuses', false) - }) - .then(() => { - return changeForeignKey(q, utils.sequelize, 'VideoTags', true) - }) - .then(() => { - return q.removeColumn('Videos', 'oldId') - }) - .then(() => { - const dataRemote = { - type: Sequelize.BOOLEAN, - defaultValue: false, - allowNull: false - } - return q.addColumn('Videos', 'remote', dataRemote) - }) - .then(() => { - const query = 'UPDATE "Videos" SET "remote" = false WHERE "remoteId" IS NULL' - return utils.sequelize.query(query) - }) - .then(() => { - const query = 'UPDATE "Videos" SET "remote" = true WHERE "remoteId" IS NOT NULL' - return utils.sequelize.query(query) - }) - .then(() => { - return q.removeColumn('Videos', 'remoteId') - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -function removeForeignKey (sequelize: Sequelize.Sequelize, tableName: string) { - const query = 'ALTER TABLE "' + tableName + '" DROP CONSTRAINT "' + tableName + '_videoId_fkey' + '"' - return sequelize.query(query) -} - -function changeForeignKey (q: Sequelize.QueryInterface, sequelize: Sequelize.Sequelize, tableName: string, allowNull: boolean) { - const data = { - type: Sequelize.INTEGER, - allowNull: true - } - - return q.addColumn(tableName, 'videoId2', data) - .then(() => { - const query = 'UPDATE "' + tableName + '" SET "videoId2" = ' + - '(SELECT "id" FROM "Videos" WHERE "' + tableName + '"."videoId" = "Videos"."oldId")' - return sequelize.query(query) - }) - .then(() => { - if (allowNull === false) { - data.allowNull = false - - return q.changeColumn(tableName, 'videoId2', data) - } - - return Promise.resolve() - }) - .then(() => { - return q.removeColumn(tableName, 'videoId') - }) - .then(() => { - return q.renameColumn(tableName, 'videoId2', 'videoId') - }) - .then(() => { - return q.addIndex(tableName, [ 'videoId' ]) - }) - .then(() => { - const constraintName = tableName + '_videoId_fkey' - const query = 'ALTER TABLE "' + tableName + '" ' + - ' ADD CONSTRAINT "' + constraintName + '"' + - ' FOREIGN KEY ("videoId") REFERENCES "Videos" ON DELETE CASCADE' - - return sequelize.query(query) - }) -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const q = utils.queryInterface - - const query = 'INSERT INTO "VideoFiles" ("videoId", "resolution", "size", "extname", "infoHash", "createdAt", "updatedAt") ' + - 'SELECT "id" AS "videoId", 0 AS "resolution", 0 AS "size", ' + - '"extname"::"text"::"enum_VideoFiles_extname" as "extname", "infoHash", "createdAt", "updatedAt" ' + - 'FROM "Videos"' - - return utils.db.VideoFile.sync() - .then(() => utils.sequelize.query(query)) - .then(() => { - return q.removeColumn('Videos', 'extname') - }) - .then(() => { - return q.removeColumn('Videos', 'infoHash') - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - throw new Error('Removed, please upgrade from a previous version first.') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.BIGINT, - allowNull: false, - defaultValue: -1 - } as Migration.BigInteger - - return q.addColumn('Users', 'videoQuota', data) - .then(() => { - data.defaultValue = null - return q.changeColumn('Users', 'videoQuota', data) - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import { readdir, rename } from 'fs-extra' -import { join } from 'path' -import * as Sequelize from 'sequelize' -import { getVideoStreamDimensionsInfo } from '../../helpers/ffmpeg/ffprobe-utils' -import { CONFIG } from '../../initializers/config' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const torrentDir = CONFIG.STORAGE.TORRENTS_DIR - const videoFileDir = CONFIG.STORAGE.VIDEOS_DIR - - return readdir(videoFileDir) - .then(videoFiles => { - const tasks: Promise[] = [] - for (const videoFile of videoFiles) { - 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) - if (matches === null) { - console.log('Invalid video file name %s.', videoFile) - continue - } - - const uuid = matches[1] - const ext = matches[2] - - const p = getVideoStreamDimensionsInfo(join(videoFileDir, videoFile)) - .then(async ({ resolution }) => { - const oldTorrentName = uuid + '.torrent' - const newTorrentName = uuid + '-' + resolution + '.torrent' - await rename(join(torrentDir, oldTorrentName), join(torrentDir, newTorrentName)).then(() => resolution) - - const newVideoFileName = uuid + '-' + resolution + '.' + ext - await rename(join(videoFileDir, videoFile), join(videoFileDir, newVideoFileName)).then(() => resolution) - - const query = 'UPDATE "VideoFiles" SET "resolution" = ' + resolution + - ' WHERE "videoId" = (SELECT "id" FROM "Videos" WHERE "uuid" = \'' + uuid + '\')' - return utils.sequelize.query(query) - }) - - tasks.push(p) - } - - return Promise.all(tasks).then(() => undefined) - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import { buildUUID } from '@shared/extra-utils' -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const q = utils.queryInterface - - // Assert not friends - - // Create uuid column for author - const dataAuthorUUID = { - type: Sequelize.UUID, - defaultValue: Sequelize.UUIDV4, - allowNull: true - } - await q.addColumn('Authors', 'uuid', dataAuthorUUID) - - // Set UUID to previous authors - { - const authors = await utils.db.Author.findAll() - for (const author of authors) { - author.uuid = buildUUID() - await author.save() - } - } - - dataAuthorUUID.allowNull = false - await q.changeColumn('Authors', 'uuid', dataAuthorUUID) - - // Create one author per user that does not already exist - const users = await utils.db.User.findAll() - for (const user of users) { - const author = await utils.db.Author.find({ where: { userId: user.id } }) - if (!author) { - await utils.db.Author.create({ - name: user.username, - podId: null, // It is our pod - userId: user.id - }) - } - } - - // Create video channels table - await utils.db.VideoChannel.sync() - - // For each author, create its default video channel - const authors = await utils.db.Author.findAll() - for (const author of authors) { - await utils.db.VideoChannel.create({ - name: `Default ${author.name} channel`, - remote: false, - authorId: author.id - }) - } - - // Create channelId column for videos - const dataChannelId = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: true - } - await q.addColumn('Videos', 'channelId', dataChannelId) - - const query = 'SELECT "id", "authorId" FROM "Videos"' - const options = { - type: Sequelize.QueryTypes.SELECT - } - const rawVideos = await utils.sequelize.query(query, options) as any - - for (const rawVideo of rawVideos) { - const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } }) - - const video = await utils.db.Video.findByPk(rawVideo.id) - video.channelId = videoChannel.id - await video.save() - } - - dataChannelId.allowNull = false - await q.changeColumn('Videos', 'channelId', dataChannelId) - - const constraintName = 'Videos_channelId_fkey' - const queryForeignKey = 'ALTER TABLE "Videos" ' + - ' ADD CONSTRAINT "' + constraintName + '"' + - ' FOREIGN KEY ("channelId") REFERENCES "VideoChannels" ON UPDATE CASCADE ON DELETE CASCADE' - - await utils.sequelize.query(queryForeignKey) - - await q.removeColumn('Videos', 'authorId') -} - -function down (options) { - // update "Applications" SET "migrationVersion" = 75; - // delete from "Authors"; - // alter table "Authors" drop column "uuid"; - // ALTER SEQUENCE "Authors_id_seq" RESTART WITH 1 - // INSERT INTO "Authors" ("name", "createdAt", "updatedAt", "userId") VALUES ('root', NOW(), NOW(), 1); - // alter table "Videos" drop column "channelId"; - // drop table "VideoChannels"; - // alter table "Videos" add column "authorId" INTEGER DEFAULT 1; - // alter table "Videos" ADD CONSTRAINT "coucou" FOREIGN KEY ("authorId") REFERENCES "Authors" - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const q = utils.queryInterface - - await q.renameColumn('Users', 'role', 'oldRole') - - const data = { - type: Sequelize.INTEGER, - allowNull: true - } - await q.addColumn('Users', 'role', data) - - let query = 'UPDATE "Users" SET "role" = 0 WHERE "oldRole" = \'admin\'' - await utils.sequelize.query(query) - - query = 'UPDATE "Users" SET "role" = 2 WHERE "oldRole" = \'user\'' - await utils.sequelize.query(query) - - data.allowNull = false - await q.changeColumn('Users', 'role', data) - - await q.removeColumn('Users', 'oldRole') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.STRING(3000), - allowNull: false - } - await q.changeColumn('Videos', 'description', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: true - } - await q.addColumn('Videos', 'privacy', data) - - const query = 'UPDATE "Videos" SET "privacy" = 1' - const options = { - type: Sequelize.QueryTypes.BULKUPDATE - } - await utils.sequelize.query(query, options) - - data.allowNull = false - await q.changeColumn('Videos', 'privacy', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' -import { shareVideoByServerAndChannel } from '../../lib/activitypub/share' -import { getLocalVideoActivityPubUrl, getLocalVideoChannelActivityPubUrl } from '../../lib/activitypub/url' -import { createLocalAccountWithoutKeys } from '../../lib/user' -import { ApplicationModel } from '../../models/application/application' -import { SERVER_ACTOR_NAME } from '../constants' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const q = utils.queryInterface - const db = utils.db - - // Assert there are no friends - { - const query = 'SELECT COUNT(*) as total FROM "Pods"' - const options = { - type: Sequelize.QueryTypes.SELECT - } - const res = await utils.sequelize.query(query, options) as any - - if (!res[0] || res[0].total !== 0) { - throw new Error('You need to quit friends.') - } - } - - // Pods -> Servers - await utils.queryInterface.renameTable('Pods', 'Servers') - - // Create Account table - await db.Account.sync() - - // Create AccountFollows table - await db.AccountFollow.sync() - - // Modify video abuse table - await db.VideoAbuse.destroy({ truncate: true }) - await utils.queryInterface.removeColumn('VideoAbuses', 'reporterPodId') - await utils.queryInterface.removeColumn('VideoAbuses', 'reporterUsername') - - // Create column link with Account table - { - const data = { - type: Sequelize.INTEGER, - allowNull: false, - references: { - model: 'Accounts', - key: 'id' - }, - onDelete: 'CASCADE' - } - await q.addColumn('VideoAbuses', 'reporterAccountId', data) - } - - // Drop request tables - await utils.queryInterface.dropTable('RequestToPods') - await utils.queryInterface.dropTable('RequestVideoEvents') - await utils.queryInterface.dropTable('RequestVideoQadus') - await utils.queryInterface.dropTable('Requests') - - // Create application account - { - const applicationInstance = await ApplicationModel.findOne() - const accountCreated = await createLocalAccountWithoutKeys({ - name: SERVER_ACTOR_NAME, - userId: null, - applicationId: applicationInstance.id, - t: undefined - }) - - const { publicKey, privateKey } = await createPrivateAndPublicKeys() - accountCreated.Actor.publicKey = publicKey - accountCreated.Actor.privateKey = privateKey - - await accountCreated.save() - } - - // Drop old video channel foreign key (referencing Authors) - { - const query = 'ALTER TABLE "VideoChannels" DROP CONSTRAINT "VideoChannels_authorId_fkey"' - await utils.sequelize.query(query) - } - - // Recreate accounts for each user - const users = await db.User.findAll() - for (const user of users) { - const account = await createLocalAccountWithoutKeys({ name: user.username, userId: user.id, applicationId: null, t: undefined }) - - const { publicKey, privateKey } = await createPrivateAndPublicKeys() - account.Actor.publicKey = publicKey - account.Actor.privateKey = privateKey - await account.save() - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - onDelete: 'CASCADE', - reference: { - model: 'Account', - key: 'id' - } - } - await q.addColumn('VideoChannels', 'accountId', data) - - { - const query = 'UPDATE "VideoChannels" SET "accountId" = ' + - '(SELECT "Accounts"."id" FROM "Accounts" INNER JOIN "Authors" ON "Authors"."userId" = "Accounts"."userId" ' + - 'WHERE "VideoChannels"."authorId" = "Authors"."id")' - await utils.sequelize.query(query) - } - - data.allowNull = false - await q.changeColumn('VideoChannels', 'accountId', data) - - await q.removeColumn('VideoChannels', 'authorId') - } - - // Add url column to "Videos" - { - const data = { - type: Sequelize.STRING, - defaultValue: null, - allowNull: true - } - await q.addColumn('Videos', 'url', data) - - const videos = await db.Video.findAll() - for (const video of videos) { - video.url = getLocalVideoActivityPubUrl(video) - await video.save() - } - - data.allowNull = false - await q.changeColumn('Videos', 'url', data) - } - - // Add url column to "VideoChannels" - { - const data = { - type: Sequelize.STRING, - defaultValue: null, - allowNull: true - } - await q.addColumn('VideoChannels', 'url', data) - - const videoChannels = await db.VideoChannel.findAll() - for (const videoChannel of videoChannels) { - videoChannel.url = getLocalVideoChannelActivityPubUrl(videoChannel) - await videoChannel.save() - } - - data.allowNull = false - await q.changeColumn('VideoChannels', 'url', data) - } - - // Loss old video rates, whatever - await utils.queryInterface.dropTable('UserVideoRates') - await db.AccountVideoRate.sync() - - { - const data = { - type: Sequelize.ENUM('transcoding', 'activitypub-http'), - defaultValue: 'transcoding', - allowNull: false - } - await q.addColumn('Jobs', 'category', data) - } - - await db.VideoShare.sync() - await db.VideoChannelShare.sync() - - { - const videos = await db.Video.findAll({ - include: [ - { - model: db.Video['sequelize'].models.VideoChannel, - include: [ - { - model: db.Video['sequelize'].models.Account, - include: [ { model: db.Video['sequelize'].models.Server, required: false } ] - } - ] - }, - { - model: db.Video['sequelize'].models.AccountVideoRate, - include: [ db.Video['sequelize'].models.Account ] - }, - { - model: db.Video['sequelize'].models.VideoShare, - include: [ db.Video['sequelize'].models.Account ] - }, - db.Video['sequelize'].models.Tag, - db.Video['sequelize'].models.VideoFile - ] - }) - - for (const video of videos) { - await shareVideoByServerAndChannel(video, undefined) - } - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - await utils.queryInterface.removeColumn('Servers', 'email') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - await utils.queryInterface.removeColumn('Servers', 'publicKey') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - await utils.db.Avatar.sync() - - const data = { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'Avatars', - key: 'id' - }, - onDelete: 'CASCADE' - } - await utils.queryInterface.addColumn('Accounts', 'avatarId', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('Videos', 'licence', data) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('Videos', 'category', data) - } - - { - const data = { - type: Sequelize.STRING(10000), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('Videos', 'description', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - await utils.queryInterface.renameTable('Applications', 'application') - await utils.queryInterface.renameTable('AccountFollows', 'accountFollow') - await utils.queryInterface.renameTable('AccountVideoRates', 'accountVideoRate') - await utils.queryInterface.renameTable('Accounts', 'account') - await utils.queryInterface.renameTable('Avatars', 'avatar') - await utils.queryInterface.renameTable('BlacklistedVideos', 'videoBlacklist') - await utils.queryInterface.renameTable('Jobs', 'job') - await utils.queryInterface.renameTable('OAuthClients', 'oAuthClient') - await utils.queryInterface.renameTable('OAuthTokens', 'oAuthToken') - await utils.queryInterface.renameTable('Servers', 'server') - await utils.queryInterface.renameTable('Tags', 'tag') - await utils.queryInterface.renameTable('Users', 'user') - await utils.queryInterface.renameTable('VideoAbuses', 'videoAbuse') - await utils.queryInterface.renameTable('VideoChannels', 'videoChannel') - await utils.queryInterface.renameTable('VideoChannelShares', 'videoChannelShare') - await utils.queryInterface.renameTable('VideoFiles', 'videoFile') - await utils.queryInterface.renameTable('VideoShares', 'videoShare') - await utils.queryInterface.renameTable('VideoTags', 'videoTag') - await utils.queryInterface.renameTable('Videos', 'video') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const q = utils.queryInterface - - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: true - } - - return q.addColumn('user', 'autoPlayVideo', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { DataType } from 'sequelize-typescript' -import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - // Create actor table - { - const queries = [ - `DROP TYPE IF EXISTS enum_actor_type`, - ` - CREATE TYPE enum_actor_type AS ENUM ( - 'Group', - 'Person', - 'Application' - ) - `, - ` - CREATE TABLE actor ( - id integer NOT NULL, - type enum_actor_type NOT NULL, - uuid uuid NOT NULL, - "preferredUsername" character varying(255) NOT NULL, - url character varying(2000) NOT NULL, - "publicKey" character varying(5000), - "privateKey" character varying(5000), - "followersCount" integer NOT NULL, - "followingCount" integer NOT NULL, - "inboxUrl" character varying(2000) NOT NULL, - "outboxUrl" character varying(2000) NOT NULL, - "sharedInboxUrl" character varying(2000) NOT NULL, - "followersUrl" character varying(2000) NOT NULL, - "followingUrl" character varying(2000) NOT NULL, - "avatarId" integer, - "serverId" integer, - "createdAt" timestamp with time zone NOT NULL, - "updatedAt" timestamp with time zone NOT NULL - );`, - `CREATE SEQUENCE actor_id_seq START WITH 1 INCREMENT BY 1 NO MINVALUE NO MAXVALUE CACHE 1`, - `ALTER SEQUENCE actor_id_seq OWNED BY actor.id`, - `ALTER TABLE ONLY actor ALTER COLUMN id SET DEFAULT nextval('actor_id_seq'::regclass)`, - `ALTER TABLE ONLY actor ADD CONSTRAINT actor_pkey PRIMARY KEY (id);`, - `CREATE UNIQUE INDEX actor_preferred_username_server_id ON actor USING btree ("preferredUsername", "serverId")`, - `ALTER TABLE ONLY actor - ADD CONSTRAINT "actor_avatarId_fkey" FOREIGN KEY ("avatarId") REFERENCES avatar(id) ON UPDATE CASCADE ON DELETE CASCADE`, - `ALTER TABLE ONLY actor - ADD CONSTRAINT "actor_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES server(id) ON UPDATE CASCADE ON DELETE CASCADE;` - ] - - for (const query of queries) { - await utils.sequelize.query(query) - } - } - - { - const query1 = - ` - INSERT INTO "actor" - ( - type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", - "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" - ) - SELECT - 'Application', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", - "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" - FROM account - WHERE "applicationId" IS NOT NULL - ` - await utils.sequelize.query(query1) - - const query2 = - ` - INSERT INTO "actor" - ( - type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", - "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" - ) - SELECT - 'Person', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", - "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" - FROM account - WHERE "applicationId" IS NULL - ` - await utils.sequelize.query(query2) - } - - { - const data = { - type: DataType.INTEGER, - allowNull: true, - references: { - model: 'actor', - key: 'id' - }, - onDelete: 'CASCADE' - } - await utils.queryInterface.addColumn('account', 'actorId', data) - - const query1 = `UPDATE account SET "actorId" = (SELECT id FROM actor WHERE actor.url = account.url)` - await utils.sequelize.query(query1) - - data.allowNull = false - await utils.queryInterface.changeColumn('account', 'actorId', data) - } - - { - const query = ` - INSERT INTO actor - ( - type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", - "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" - ) - SELECT - 'Group', "videoChannel".uuid, "videoChannel".uuid, "videoChannel".url, null, null, 0, 0, "videoChannel".url || '/inbox', - "videoChannel".url || '/outbox', "videoChannel".url || '/inbox', "videoChannel".url || '/followers', "videoChannel".url || '/following', - null, account."serverId", "videoChannel"."createdAt", "videoChannel"."updatedAt" - FROM "videoChannel" - INNER JOIN "account" on "videoChannel"."accountId" = "account".id - ` - await utils.sequelize.query(query) - } - - { - const data = { - type: DataType.INTEGER, - allowNull: true, - references: { - model: 'actor', - key: 'id' - }, - onDelete: 'CASCADE' - } - await utils.queryInterface.addColumn('videoChannel', 'actorId', data) - - const query1 = `UPDATE "videoChannel" SET "actorId" = (SELECT id FROM actor WHERE actor.url = "videoChannel".url)` - await utils.sequelize.query(query1) - - data.allowNull = false - await utils.queryInterface.changeColumn('videoChannel', 'actorId', data) - } - - { - await utils.queryInterface.renameTable('accountFollow', 'actorFollow') - await utils.queryInterface.renameColumn('actorFollow', 'accountId', 'actorId') - await utils.queryInterface.renameColumn('actorFollow', 'targetAccountId', 'targetActorId') - - try { - await utils.queryInterface.removeConstraint('actorFollow', 'AccountFollows_accountId_fkey') - await utils.queryInterface.removeConstraint('actorFollow', 'AccountFollows_targetAccountId_fkey') - } catch { - await utils.queryInterface.removeConstraint('actorFollow', 'accountFollow_accountId_fkey') - await utils.queryInterface.removeConstraint('actorFollow', 'accountFollow_targetAccountId_fkey') - } - - { - const query1 = `UPDATE "actorFollow" - SET "actorId" = - (SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."actorId")` - await utils.sequelize.query(query1) - - const query2 = `UPDATE "actorFollow" - SET "targetActorId" = - (SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."targetActorId")` - - await utils.sequelize.query(query2) - } - - { - const query1 = `ALTER TABLE ONLY "actorFollow" - ADD CONSTRAINT "actorFollow_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;` - await utils.sequelize.query(query1) - - const query2 = `ALTER TABLE ONLY "actorFollow" - ADD CONSTRAINT "actorFollow_targetActorId_fkey" FOREIGN KEY ("targetActorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;` - await utils.sequelize.query(query2) - } - } - - { - await utils.queryInterface.renameColumn('videoShare', 'accountId', 'actorId') - - try { - await utils.queryInterface.removeConstraint('videoShare', 'VideoShares_accountId_fkey') - } catch { - await utils.queryInterface.removeConstraint('videoShare', 'videoShare_accountId_fkey') - } - - const query = `UPDATE "videoShare" - SET "actorId" = - (SELECT "actorId" FROM account WHERE id = "videoShare"."actorId")` - await utils.sequelize.query(query) - - { - const query1 = `ALTER TABLE ONLY "videoShare" - ADD CONSTRAINT "videoShare_actorId_fkey" FOREIGN KEY ("actorId") REFERENCES actor(id) ON UPDATE CASCADE ON DELETE CASCADE;` - await utils.sequelize.query(query1) - - const query2 = `ALTER TABLE ONLY "videoShare" - ADD CONSTRAINT "videoShare_videoId_fkey" FOREIGN KEY ("videoId") REFERENCES video(id) ON UPDATE CASCADE ON DELETE CASCADE;` - await utils.sequelize.query(query2) - } - } - - { - const columnsToDelete = [ - 'uuid', - 'url', - 'publicKey', - 'privateKey', - 'followersCount', - 'followingCount', - 'inboxUrl', - 'outboxUrl', - 'sharedInboxUrl', - 'followersUrl', - 'followingUrl', - 'serverId', - 'avatarId' - ] - for (const columnToDelete of columnsToDelete) { - await utils.queryInterface.removeColumn('account', columnToDelete) - } - } - - { - const columnsToDelete = [ - 'uuid', - 'remote', - 'url' - ] - for (const columnToDelete of columnsToDelete) { - await utils.queryInterface.removeColumn('videoChannel', columnToDelete) - } - } - - { - const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL' - const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT } - const [ res ] = await utils.sequelize.query(query, options) - - for (const actor of res) { - const { privateKey, publicKey } = await createPrivateAndPublicKeys() - - const queryUpdate = `UPDATE "actor" SET "publicKey" = '${publicKey}', "privateKey" = '${privateKey}' WHERE id = ${actor.id}` - await utils.sequelize.query(queryUpdate) - } - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { WEBSERVER } from '../constants' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const toReplace = WEBSERVER.HOSTNAME + ':443' - const by = WEBSERVER.HOST - const replacer = column => `replace("${column}", '${toReplace}', '${by}')` - - { - const query = `UPDATE video SET url = ${replacer('url')}` - await utils.sequelize.query(query) - } - - { - const query = ` - UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')}, - "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')}, - "followingUrl" = ${replacer('followingUrl')} - ` - await utils.sequelize.query(query) - } - - { - const query = `UPDATE server SET host = replace(host, ':443', '')` - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - await utils.queryInterface.dropTable('Authors') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - await utils.queryInterface.removeConstraint('actor', 'actor_avatarId_fkey') - - await utils.queryInterface.addConstraint('actor', { - fields: [ 'avatarId' ], - type: 'foreign key', - references: { - table: 'avatar', - field: 'id' - }, - onDelete: 'set null', - onUpdate: 'CASCADE' - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: true - } as Migration.Boolean - await utils.queryInterface.addColumn('video', 'commentsEnabled', data) - - data.defaultValue = null - return utils.queryInterface.changeColumn('video', 'commentsEnabled', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const toReplace = ':443' - const by = '' - const replacer = column => `replace("${column}", '${toReplace}', '${by}')` - - const query = ` - UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')}, - "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')}, - "followingUrl" = ${replacer('followingUrl')} - ` - await utils.sequelize.query(query) - } - - { - const toReplace = '/account/' - const by = '/accounts/' - const replacer = column => `replace("${column}", '${toReplace}', '${by}')` - - const query = ` - UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')}, - "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')}, - "followingUrl" = ${replacer('followingUrl')} - ` - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const toReplace = ':443' - const by = '' - const replacer = column => `replace("${column}", '${toReplace}', '${by}')` - - const query = `UPDATE video SET url = ${replacer('url')}` - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { ACTOR_FOLLOW_SCORE } from '../constants' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - await utils.queryInterface.removeColumn('server', 'score') - - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: ACTOR_FOLLOW_SCORE.BASE - } - - await utils.queryInterface.addColumn('actorFollow', 'score', data) - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const query = 'UPDATE "actor" SET ' + - '"followersCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."targetActorId"), ' + - '"followingCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."actorId") ' + - 'WHERE "actor"."serverId" IS NULL' - - await utils.sequelize.query(query) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - await utils.queryInterface.dropTable('job') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const query = 'DELETE FROM "videoShare" s1 ' + - 'USING (SELECT MIN(id) as id, "actorId", "videoId" FROM "videoShare" GROUP BY "actorId", "videoId" HAVING COUNT(*) > 1) s2 ' + - 'WHERE s1."actorId" = s2."actorId" AND s1."videoId" = s2."videoId" AND s1.id <> s2.id' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.STRING, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoShare', 'url', data) - - const query = `UPDATE "videoShare" SET "url" = (SELECT "url" FROM "video" WHERE "id" = "videoId") || '/announces/' || "actorId"` - await utils.sequelize.query(query) - - data.allowNull = false - await utils.queryInterface.changeColumn('videoShare', 'url', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const query = 'DELETE FROM "videoComment" s1 ' + - 'USING (SELECT MIN(id) as id, url FROM "videoComment" GROUP BY "url" HAVING COUNT(*) > 1) s2 ' + - 'WHERE s1."url" = s2."url" AND s1.id <> s2.id' - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.STRING(500), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('video', 'support', data) - } - - { - const data = { - type: Sequelize.STRING(500), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoChannel', 'support', data) - } - - { - const data = { - type: Sequelize.STRING(250), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('account', 'description', data) - } - - { - const data = { - type: Sequelize.STRING(10000), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('video', 'description', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const data = { - type: Sequelize.DATE, - allowNull: true, - defaultValue: Sequelize.NOW - } - await utils.queryInterface.addColumn('video', 'publishedAt', data) - } - - { - const query = 'UPDATE video SET "publishedAt" = video."createdAt"' - await utils.sequelize.query(query) - } - - // Sequelize does not alter the column with NOW as default value - { - const data = { - type: Sequelize.DATE, - allowNull: false, - defaultValue: Sequelize.NOW - } - await utils.queryInterface.changeColumn('video', 'publishedAt', data) - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const data = { - type: Sequelize.ENUM('do_not_list', 'blur', 'display'), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('user', 'nsfwPolicy', data) - } - - { - const query = 'UPDATE "user" SET "nsfwPolicy" = \'do_not_list\'' - await utils.sequelize.query(query) - } - - { - const query = 'UPDATE "user" SET "nsfwPolicy" = \'display\' WHERE "displayNSFW" = true' - await utils.sequelize.query(query) - } - - { - const query = 'ALTER TABLE "user" ALTER COLUMN "nsfwPolicy" SET NOT NULL' - await utils.sequelize.query(query) - } - - { - await utils.queryInterface.removeColumn('user', 'displayNSFW') - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../constants' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - await utils.queryInterface.renameColumn('video', 'language', 'oldLanguage') - } - - { - const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.LANGUAGE.max), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('video', 'language', data) - } - - { - const languages = [ - { - oldLanguage: 1, - newLanguage: 'en' - }, - { - oldLanguage: 2, - newLanguage: 'es' - }, - { - oldLanguage: 3, - newLanguage: 'zh' - }, - { - oldLanguage: 4, - newLanguage: 'hi' - }, - { - oldLanguage: 5, - newLanguage: 'ar' - }, - { - oldLanguage: 6, - newLanguage: 'pt' - }, - { - oldLanguage: 7, - newLanguage: 'bn' - }, - { - oldLanguage: 8, - newLanguage: 'ru' - }, - { - oldLanguage: 9, - newLanguage: 'ja' - }, - { - oldLanguage: 10, - newLanguage: 'pa' - }, - { - oldLanguage: 11, - newLanguage: 'de' - }, - { - oldLanguage: 12, - newLanguage: 'ko' - }, - { - oldLanguage: 13, - newLanguage: 'fr' - }, - { - oldLanguage: 14, - newLanguage: 'it' - }, - { - oldLanguage: 1000, - newLanguage: 'sgn' - }, - { - oldLanguage: 1001, - newLanguage: 'ase' - }, - { - oldLanguage: 1002, - newLanguage: 'sdl' - }, - { - oldLanguage: 1003, - newLanguage: 'bfi' - }, - { - oldLanguage: 1004, - newLanguage: 'bzs' - }, - { - oldLanguage: 1005, - newLanguage: 'csl' - }, - { - oldLanguage: 1006, - newLanguage: 'cse' - }, - { - oldLanguage: 1007, - newLanguage: 'dsl' - }, - { - oldLanguage: 1008, - newLanguage: 'fsl' - }, - { - oldLanguage: 1009, - newLanguage: 'gsg' - }, - { - oldLanguage: 1010, - newLanguage: 'pks' - }, - { - oldLanguage: 1011, - newLanguage: 'jsl' - }, - { - oldLanguage: 1012, - newLanguage: 'sfs' - }, - { - oldLanguage: 1013, - newLanguage: 'swl' - }, - { - oldLanguage: 1014, - newLanguage: 'rsl' - } - ] - - for (const language of languages) { - const query = 'UPDATE "video" SET "language" = \'' + language.newLanguage + '\' WHERE "oldLanguage" = ' + language.oldLanguage - await utils.sequelize.query(query) - } - } - - { - await utils.queryInterface.removeColumn('video', 'oldLanguage') - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.STRING(500), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('video', 'support', data) - } - - { - const data = { - type: Sequelize.STRING(500), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('videoChannel', 'support', data) - } - - { - const data = { - type: Sequelize.STRING(500), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('videoChannel', 'description', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - // waitingTranscoding column - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('video', 'waitTranscoding', data) - } - - { - const query = 'UPDATE video SET "waitTranscoding" = false' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: null - } - await utils.queryInterface.changeColumn('video', 'waitTranscoding', data) - } - - // state - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('video', 'state', data) - } - - { - // Published - const query = 'UPDATE video SET "state" = 1' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: null - } - await utils.queryInterface.changeColumn('video', 'state', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoFile', 'fps', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - await utils.sequelize.query('DROP INDEX IF EXISTS video_id_privacy_state_wait_transcoding;') - await utils.sequelize.query('DROP INDEX IF EXISTS video_name;') - - for (let i = 0; i < 5; i++) { - const query = 'DELETE FROM "videoFile" WHERE id IN ' + - '(SELECT id FROM (SELECT MIN(id) AS id, "videoId", "resolution", "fps" ' + - 'FROM "videoFile" GROUP BY "videoId", "resolution", "fps" HAVING COUNT(*) > 1) t)' - await utils.sequelize.query(query) - } - - for (let i = 0; i < 5; i++) { - const query = 'DELETE FROM "actor" WHERE id IN ' + - '(SELECT id FROM (SELECT MIN(id) AS id, "uuid" ' + - 'FROM "actor" GROUP BY "uuid" HAVING COUNT(*) > 1) t)' - await utils.sequelize.query(query) - } - - for (let i = 0; i < 5; i++) { - const query = 'DELETE FROM "account" WHERE id IN ' + - '(SELECT id FROM (SELECT MIN(id) AS id, "actorId" ' + - 'FROM "account" GROUP BY "actorId" HAVING COUNT(*) > 1) t)' - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - const indexNames = [ - 'accounts_application_id', - 'accounts_user_id', - 'accounts_name', - - 'account_video_rates_video_id_account_id', - 'account_video_rates_video_id_account_id_type', - - 'account_follows_account_id_target_account_id', - 'account_follow_account_id_target_account_id', - 'account_follow_account_id', - 'account_follow_target_account_id', - 'account_follows_account_id', - 'account_follows_target_account_id', - - 'o_auth_clients_client_id', - 'o_auth_clients_client_id_client_secret', - - 'o_auth_tokens_access_token', - 'o_auth_tokens_refresh_token', - 'o_auth_tokens_o_auth_client_id', - 'o_auth_tokens_user_id', - - 'pods_host', - 'servers_host', - - 'tags_name', - - 'users_email', - 'users_username', - - 'videos_channel_id', - 'videos_created_at', - 'videos_duration', - 'videos_likes', - 'videos_name', - 'videos_uuid', - 'videos_views', - - 'video_abuses_reporter_account_id', - 'video_abuses_video_id', - - 'blacklisted_videos_video_id', - - 'video_channels_account_id', - - 'video_files_info_hash', - 'video_files_video_id', - - 'video_shares_account_id', - 'video_shares_video_id', - - 'video_tags_tag_id', - 'video_tags_video_id' - ] - - for (const indexName of indexNames) { - await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";') - } - - await utils.sequelize.query('ALTER TABLE "account" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') - await utils.sequelize.query('ALTER TABLE "videoChannel" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";') - await utils.sequelize.query('ALTER TABLE "videoShare" DROP CONSTRAINT IF EXISTS "VideoShares_videoId_fkey";') - - await utils.sequelize.query('DROP TABLE IF EXISTS "videoChannelShare";') -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('user', 'blocked', data) - } - - { - const query = 'UPDATE "user" SET "blocked" = false' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: null - } - await utils.queryInterface.changeColumn('user', 'blocked', data) - } - - { - const data = { - type: Sequelize.STRING(250), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('user', 'blockedReason', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' -import { AbuseState } from '../../../shared/models' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoAbuse', 'state', data) - } - - { - const query = 'UPDATE "videoAbuse" SET "state" = ' + AbuseState.PENDING - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: null - } - await utils.queryInterface.changeColumn('videoAbuse', 'state', data) - } - - { - const data = { - type: Sequelize.STRING(300), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoAbuse', 'moderationComment', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const data = { - type: Sequelize.STRING(300), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoBlacklist', 'reason', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.BIGINT, - allowNull: false, - defaultValue: -1 - } - await utils.queryInterface.addColumn('user', 'videoQuotaDaily', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('user', 'emailVerified', data) - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - } - - await utils.queryInterface.addColumn('server', 'redundancyAllowed', data) - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - // Delete duplicated keys - { - const query = 'DELETE FROM "server" s1 USING "server" s2 WHERE s1.id < s2.id AND s1."host" = s2."host"' - await utils.sequelize.query(query) - } - - { - const query = 'DELETE FROM "videoFile" vf1 USING "videoFile" vf2 WHERE vf1.id < vf2.id ' + - 'AND vf1."videoId" = vf2."videoId" AND vf1.resolution = vf2.resolution AND vf1.fps IS NULL' - await utils.sequelize.query(query) - } - - { - const query = 'UPDATE "videoFile" SET fps = -1 WHERE fps IS NULL;' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: -1 - } - await utils.queryInterface.changeColumn('videoFile', 'fps', data) - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: true - } - - await utils.queryInterface.addColumn('user', 'webTorrentEnabled', data) - } - -} - -async function down (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - await utils.queryInterface.removeColumn('user', 'webTorrentEnabled') -} - -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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.STRING(1000), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('video', 'support', data) - } - - { - const data = { - type: Sequelize.STRING(1000), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('videoChannel', 'support', data) - } - - { - const data = { - type: Sequelize.STRING(1000), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('videoChannel', 'description', data) - } - - { - const data = { - type: Sequelize.STRING(1000), - allowNull: true, - defaultValue: null - } - await utils.queryInterface.changeColumn('account', 'description', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.STRING(2000), - allowNull: true - } - - await utils.queryInterface.addColumn('accountVideoRate', 'url', data) - } - - { - const builtUrlQuery = `SELECT "actor"."url" || '/' || "accountVideoRate"."type" || 's/' || "videoId" ` + - 'FROM "accountVideoRate" ' + - 'INNER JOIN account ON account.id = "accountVideoRate"."accountId" ' + - 'INNER JOIN actor ON actor.id = account."actorId" ' + - 'WHERE "base".id = "accountVideoRate".id' - - const query = 'UPDATE "accountVideoRate" base SET "url" = (' + builtUrlQuery + ') WHERE "url" IS NULL' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.STRING(2000), - allowNull: false, - defaultValue: null - } - await utils.queryInterface.changeColumn('accountVideoRate', 'url', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - await utils.queryInterface.renameColumn('videoFile', 'extname', 'extname_old') - } - - { - const data = { - type: Sequelize.STRING, - defaultValue: null, - allowNull: true - } - - await utils.queryInterface.addColumn('videoFile', 'extname', data) - } - - { - const query = 'UPDATE "videoFile" SET "extname" = "extname_old"::text' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.STRING, - defaultValue: null, - allowNull: false - } - await utils.queryInterface.changeColumn('videoFile', 'extname', data) - } - - { - await utils.queryInterface.removeColumn('videoFile', 'extname_old') - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: true - } - - await utils.queryInterface.addColumn('user', 'videosHistoryEnabled', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const query = `INSERT INTO "videoShare" (url, "actorId", "videoId", "createdAt", "updatedAt") ` + - `(` + - `SELECT ` + - `video.url || '/announces/' || "videoChannel"."actorId" as url, ` + - `"videoChannel"."actorId" AS "actorId", ` + - `"video"."id" AS "videoId", ` + - `NOW() AS "createdAt", ` + - `NOW() AS "updatedAt" ` + - `FROM video ` + - `INNER JOIN "videoChannel" ON "video"."channelId" = "videoChannel"."id" ` + - `WHERE "video"."remote" = false AND "video"."privacy" != 3 AND "video"."state" = 1` + - `) ` + - `ON CONFLICT DO NOTHING` - - await utils.sequelize.query(query) - } - - { - const query = `INSERT INTO "videoShare" (url, "actorId", "videoId", "createdAt", "updatedAt") ` + - `(` + - `SELECT ` + - `video.url || '/announces/' || (SELECT id FROM actor WHERE "preferredUsername" = 'peertube' ORDER BY id ASC LIMIT 1) as url, ` + - `(SELECT id FROM actor WHERE "preferredUsername" = 'peertube' ORDER BY id ASC LIMIT 1) AS "actorId", ` + - `"video"."id" AS "videoId", ` + - `NOW() AS "createdAt", ` + - `NOW() AS "updatedAt" ` + - `FROM video ` + - `WHERE "video"."remote" = false AND "video"."privacy" != 3 AND "video"."state" = 1` + - `) ` + - `ON CONFLICT DO NOTHING` - - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const indexNames = [ - 'video_category', - 'video_licence', - 'video_nsfw', - 'video_language', - 'video_wait_transcoding', - 'video_state', - 'video_remote', - 'video_likes' - ] - - for (const indexName of indexNames) { - await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";') - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const query = ` -CREATE TABLE IF NOT EXISTS "userNotificationSetting" ("id" SERIAL, -"newVideoFromSubscription" INTEGER NOT NULL DEFAULT NULL, -"newCommentOnMyVideo" INTEGER NOT NULL DEFAULT NULL, -"videoAbuseAsModerator" INTEGER NOT NULL DEFAULT NULL, -"blacklistOnMyVideo" INTEGER NOT NULL DEFAULT NULL, -"myVideoPublished" INTEGER NOT NULL DEFAULT NULL, -"myVideoImportFinished" INTEGER NOT NULL DEFAULT NULL, -"newUserRegistration" INTEGER NOT NULL DEFAULT NULL, -"newFollow" INTEGER NOT NULL DEFAULT NULL, -"commentMention" INTEGER NOT NULL DEFAULT NULL, -"userId" INTEGER REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE, -"createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, -"updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, -PRIMARY KEY ("id")) -` - await utils.sequelize.query(query) - } - - { - const query = 'INSERT INTO "userNotificationSetting" ' + - '("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' + - '"myVideoPublished", "myVideoImportFinished", "newUserRegistration", "newFollow", "commentMention", ' + - '"userId", "createdAt", "updatedAt") ' + - '(SELECT 1, 1, 3, 3, 1, 1, 1, 1, 1, id, NOW(), NOW() FROM "user")' - - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - } - - await utils.queryInterface.addColumn('videoBlacklist', 'unfederated', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const data = { - type: Sequelize.STRING(3000), - allowNull: false, - defaultValue: null - } - - await utils.queryInterface.changeColumn('videoAbuse', 'reason', data) - } - - { - const data = { - type: Sequelize.STRING(3000), - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.changeColumn('videoAbuse', 'moderationComment', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const query = ` - CREATE TABLE IF NOT EXISTS "videoStreamingPlaylist" -( - "id" SERIAL, - "type" INTEGER NOT NULL, - "playlistUrl" VARCHAR(2000) NOT NULL, - "p2pMediaLoaderInfohashes" VARCHAR(255)[] NOT NULL, - "segmentsSha256Url" VARCHAR(255) NOT NULL, - "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - PRIMARY KEY ("id") -);` - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.changeColumn('videoRedundancy', 'videoFileId', data) - } - - { - const query = 'ALTER TABLE "videoRedundancy" ADD COLUMN "videoStreamingPlaylistId" INTEGER NULL ' + - 'REFERENCES "videoStreamingPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE' - - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { Migration } from '../../models/migrations' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: true - } as Migration.Boolean - await utils.queryInterface.addColumn('video', 'downloadEnabled', data) - - data.defaultValue = null - return utils.queryInterface.changeColumn('video', 'downloadEnabled', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - const data = { - type: Sequelize.DATE, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('video', 'originallyPublishedAt', data) - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { buildUUID } from '@shared/extra-utils' -import { VideoPlaylistPrivacy, VideoPlaylistType } from '../../../shared/models/videos' -import { WEBSERVER } from '../constants' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - const transaction = utils.transaction - - { - const query = ` -CREATE TABLE IF NOT EXISTS "videoPlaylist" -( - "id" SERIAL, - "name" VARCHAR(255) NOT NULL, - "description" VARCHAR(255), - "privacy" INTEGER NOT NULL, - "url" VARCHAR(2000) NOT NULL, - "uuid" UUID NOT NULL, - "type" INTEGER NOT NULL DEFAULT 1, - "ownerAccountId" INTEGER NOT NULL REFERENCES "account" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "videoChannelId" INTEGER REFERENCES "videoChannel" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - PRIMARY KEY ("id") -);` - await utils.sequelize.query(query, { transaction }) - } - - { - const query = ` -CREATE TABLE IF NOT EXISTS "videoPlaylistElement" -( - "id" SERIAL, - "url" VARCHAR(2000) NOT NULL, - "position" INTEGER NOT NULL DEFAULT 1, - "startTimestamp" INTEGER, - "stopTimestamp" INTEGER, - "videoPlaylistId" INTEGER NOT NULL REFERENCES "videoPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "videoId" INTEGER NOT NULL REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - PRIMARY KEY ("id") -);` - - await utils.sequelize.query(query, { transaction }) - } - - { - const userQuery = 'SELECT "username" FROM "user";' - - const options = { transaction, type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT } - const userResult = await utils.sequelize.query<{ username: string }>(userQuery, options) - const usernames = userResult.map(r => r.username) - - for (const username of usernames) { - const uuid = buildUUID() - - const baseUrl = WEBSERVER.URL + '/video-playlists/' + uuid - const query = ` - INSERT INTO "videoPlaylist" ("url", "uuid", "name", "privacy", "type", "ownerAccountId", "createdAt", "updatedAt") - SELECT '${baseUrl}' AS "url", - '${uuid}' AS "uuid", - 'Watch later' AS "name", - ${VideoPlaylistPrivacy.PRIVATE} AS "privacy", - ${VideoPlaylistType.WATCH_LATER} AS "type", - "account"."id" AS "ownerAccountId", - NOW() as "createdAt", - NOW() as "updatedAt" - FROM "user" INNER JOIN "account" ON "user"."id" = "account"."userId" - WHERE "user"."username" = '${username}'` - - await utils.sequelize.query(query, { transaction }) - } - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' -import { VideoBlacklistType } from '../../../shared/models/videos' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('videoBlacklist', 'type', data) - } - - { - const query = 'UPDATE "videoBlacklist" SET "type" = ' + VideoBlacklistType.MANUAL - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: null - } - await utils.queryInterface.changeColumn('videoBlacklist', 'type', data) - } - - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: true - } - await utils.queryInterface.addColumn('userNotificationSetting', 'videoAutoBlacklistAsModerator', data) - } - - { - const query = 'UPDATE "userNotificationSetting" SET "videoAutoBlacklistAsModerator" = 3' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: false - } - await utils.queryInterface.changeColumn('userNotificationSetting', 'videoAutoBlacklistAsModerator', data) - } -} -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoStreamingPlaylist', 'p2pMediaLoaderPeerVersion', data) - } - - { - const query = `UPDATE "videoStreamingPlaylist" SET "p2pMediaLoaderPeerVersion" = 0;` - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: false, - defaultValue: null - } - await utils.queryInterface.changeColumn('videoStreamingPlaylist', 'p2pMediaLoaderPeerVersion', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: true - } - await utils.queryInterface.addColumn('userNotificationSetting', 'newInstanceFollower', data) - } - - { - const query = 'UPDATE "userNotificationSetting" SET "newInstanceFollower" = 1' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: false - } - await utils.queryInterface.changeColumn('userNotificationSetting', 'newInstanceFollower', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: true - } - await utils.queryInterface.addColumn('user', 'adminFlags', data) - } - - { - const query = 'UPDATE "user" SET "adminFlags" = 0' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: false - } - await utils.queryInterface.changeColumn('user', 'adminFlags', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const query = ` -CREATE TABLE IF NOT EXISTS "thumbnail" -( - "id" SERIAL, - "filename" VARCHAR(255) NOT NULL, - "height" INTEGER DEFAULT NULL, - "width" INTEGER DEFAULT NULL, - "type" INTEGER NOT NULL, - "fileUrl" VARCHAR(255), - "videoId" INTEGER REFERENCES "video" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "videoPlaylistId" INTEGER REFERENCES "videoPlaylist" ("id") ON DELETE CASCADE ON UPDATE CASCADE, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - PRIMARY KEY ("id") -);` - await utils.sequelize.query(query) - } - - { - // All video thumbnails - const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' + - 'SELECT uuid || \'.jpg\', 1, id, 110, 200, NOW(), NOW() FROM "video"' - await utils.sequelize.query(query) - } - - { - // All video previews - const query = 'INSERT INTO "thumbnail" ("filename", "type", "videoId", "height", "width", "createdAt", "updatedAt")' + - 'SELECT uuid || \'.jpg\', 2, id, 315, 560, NOW(), NOW() FROM "video"' - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const data = { - type: Sequelize.STRING(1000), - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.changeColumn('account', 'description', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - try { - await utils.queryInterface.removeColumn('application', 'createdAt') - } catch { /* the column could not exist */ } - - try { - await utils.queryInterface.removeColumn('application', 'updatedAt') - } catch { /* the column could not exist */ } - - try { - await utils.queryInterface.removeColumn('videoView', 'updatedAt') - } catch { /* the column could not exist */ } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - await utils.queryInterface.removeColumn('actor', 'uuid') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const data = { - type: Sequelize.STRING(400), - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('user', 'pendingEmail', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const data = { - type: Sequelize.ARRAY(Sequelize.STRING), - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('user', 'videoLanguages', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const data = { - type: Sequelize.STRING, - allowNull: false, - defaultValue: 'instance-default' - } - - await utils.queryInterface.addColumn('user', 'theme', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const query = ` -CREATE TABLE IF NOT EXISTS "plugin" -( - "id" SERIAL, - "name" VARCHAR(255) NOT NULL, - "type" INTEGER NOT NULL, - "version" VARCHAR(255) NOT NULL, - "latestVersion" VARCHAR(255), - "enabled" BOOLEAN NOT NULL, - "uninstalled" BOOLEAN NOT NULL, - "peertubeEngine" VARCHAR(255) NOT NULL, - "description" VARCHAR(255), - "homepage" VARCHAR(255) NOT NULL, - "settings" JSONB, - "storage" JSONB, - "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, - "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, - PRIMARY KEY ("id") -);` - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.changeColumn('videoPlaylistElement', 'videoId', data) - } - - await utils.queryInterface.removeConstraint('videoPlaylistElement', 'videoPlaylistElement_videoId_fkey') - - await utils.queryInterface.addConstraint('videoPlaylistElement', { - fields: [ 'videoId' ], - type: 'foreign key', - references: { - table: 'video', - field: 'id' - }, - onDelete: 'set null', - onUpdate: 'CASCADE' - }) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('thumbnail', 'automaticallyGenerated', data) - } - - { - // Set auto generated to true for watch later playlists - const query = 'UPDATE thumbnail SET "automaticallyGenerated" = true WHERE "videoPlaylistId" IN ' + - '(SELECT id FROM "videoPlaylist" WHERE type = 2)' - - await utils.sequelize.query(query) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - // We'll add a unique index on filename, so delete duplicates or PeerTube won't start - const query = 'DELETE FROM "avatar" s1 ' + - 'USING (SELECT MIN(id) as id, filename FROM "avatar" GROUP BY "filename" HAVING COUNT(*) > 1) s2 ' + - 'WHERE s1."filename" = s2."filename" AND s1.id <> s2.id' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.STRING, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('avatar', 'fileUrl', data) - } - - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('avatar', 'onDisk', data) - } - - { - const query = 'UPDATE "avatar" SET "onDisk" = true;' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: null - } - - await utils.queryInterface.changeColumn('avatar', 'onDisk', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - const data = { - type: Sequelize.STRING, - allowNull: true - } - - await utils.queryInterface.changeColumn('actor', 'outboxUrl', data) - await utils.queryInterface.changeColumn('actor', 'followersUrl', data) - await utils.queryInterface.changeColumn('actor', 'followingUrl', data) -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: true - } - await utils.queryInterface.addColumn('userNotificationSetting', 'autoInstanceFollowing', data) - } - - { - const query = 'UPDATE "userNotificationSetting" SET "autoInstanceFollowing" = 1' - await utils.sequelize.query(query) - } - - { - const data = { - type: Sequelize.INTEGER, - defaultValue: null, - allowNull: false - } - await utils.queryInterface.changeColumn('userNotificationSetting', 'autoInstanceFollowing', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - } - - await utils.queryInterface.addColumn('user', 'noInstanceConfigWarningModal', data) - } - - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: true - } - - await utils.queryInterface.addColumn('user', 'noWelcomeModal', data) - data.defaultValue = false - - await utils.queryInterface.changeColumn('user', 'noWelcomeModal', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: false - } - - await utils.queryInterface.addColumn('user', 'autoPlayNextVideo', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.STRING, - allowNull: true - } - - await utils.queryInterface.changeColumn('actor', 'sharedInboxUrl', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - references: { - model: 'videoStreamingPlaylist', - key: 'id' - }, - onDelete: 'CASCADE' - } - - await utils.queryInterface.addColumn('videoFile', 'videoStreamingPlaylistId', data) - } - - { - const data = { - type: Sequelize.INTEGER, - allowNull: true - } - - await utils.queryInterface.changeColumn('videoFile', 'videoId', data) - } - - { - await utils.queryInterface.removeIndex('videoFile', 'video_file_video_id_resolution_fps') - } - - { - const query = 'insert into "videoFile" ' + - '(resolution, size, "infoHash", "videoId", "createdAt", "updatedAt", fps, extname, "videoStreamingPlaylistId")' + - '(SELECT "videoFile".resolution, "videoFile".size, \'fake\', NULL, "videoFile"."createdAt", "videoFile"."updatedAt", ' + - '"videoFile"."fps", "videoFile".extname, "videoStreamingPlaylist".id FROM "videoStreamingPlaylist" ' + - 'inner join video ON video.id = "videoStreamingPlaylist"."videoId" inner join "videoFile" ON "videoFile"."videoId" = video.id)' - - await utils.sequelize.query(query, { transaction: utils.transaction }) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.INTEGER, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.changeColumn('videoComment', 'accountId', data) - } - - { - const data = { - type: Sequelize.DATE, - allowNull: true, - defaultValue: null - } - await utils.queryInterface.addColumn('videoComment', 'deletedAt', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.BOOLEAN, - allowNull: false, - defaultValue: true - } - - await utils.queryInterface.addColumn('user', 'autoPlayNextVideoPlaylist', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.STRING(2000), - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.changeColumn('thumbnail', 'fileUrl', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - await utils.sequelize.query('DROP INDEX IF EXISTS video_share_account_id;') - await utils.sequelize.query('DROP INDEX IF EXISTS video_published_at;') - - await utils.sequelize.query('ALTER TABLE "avatar" DROP COLUMN IF EXISTS "avatarId"') -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.DATE, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.changeColumn('videoRedundancy', 'expiresOn', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize - db: any -}): Promise { - { - const data = { - type: Sequelize.STRING, - allowNull: true, - defaultValue: null - } - - await utils.queryInterface.addColumn('videoCaption', 'fileUrl', data) - } -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - const deletedVideo = { - type: Sequelize.JSONB, - allowNull: true - } - await utils.queryInterface.addColumn('videoAbuse', 'deletedVideo', deletedVideo) - await utils.sequelize.query(`ALTER TABLE "videoAbuse" ALTER COLUMN "videoId" DROP NOT NULL;`) - await utils.sequelize.query(`ALTER TABLE "videoAbuse" DROP CONSTRAINT IF EXISTS "videoAbuse_videoId_fkey";`) - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const password = { - type: Sequelize.STRING, - allowNull: true - } - await utils.queryInterface.changeColumn('user', 'password', password) - } - - { - const pluginAuth = { - type: Sequelize.STRING, - allowNull: true - } - await utils.queryInterface.addColumn('user', 'pluginAuth', pluginAuth) - } - - { - const authName = { - type: Sequelize.STRING, - allowNull: true - } - await utils.queryInterface.addColumn('oAuthToken', 'authName', authName) - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} 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 @@ -import * as Sequelize from 'sequelize' - -async function up (utils: { - transaction: Sequelize.Transaction - queryInterface: Sequelize.QueryInterface - sequelize: Sequelize.Sequelize -}): Promise { - - { - const description = { - type: Sequelize.STRING(1000), - allowNull: true - } - await utils.queryInterface.changeColumn('videoPlaylist', 'description', description) - } - -} - -function down (options) { - throw new Error('Not implemented.') -} - -export { - up, - down -} -- cgit v1.2.3