From 4805cff179cbf518abb4c1b494b477c71f84b989 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 29 Jan 2018 11:58:07 +0100 Subject: [PATCH] Fix migrations --- scripts/release.sh | 1 - server/initializers/constants.ts | 2 +- .../0190-video-comment-unique-url.ts | 23 +++++++++++++++++++ support/doc/production.md | 21 +++++++++-------- 4 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 server/initializers/migrations/0190-video-comment-unique-url.ts diff --git a/scripts/release.sh b/scripts/release.sh index 0a78fe990..0e288a49c 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -53,7 +53,6 @@ zip -r "PeerTube/$zip_name" "$directory_name/CREDITS.md" "$directory_name/FAQ.md "$directory_name/dist" "$directory_name/package.json" \ "$directory_name/scripts" "$directory_name/support" \ "$directory_name/tsconfig.json" "$directory_name/yarn.lock" \ - "$directory_name/server/" "$directory_name/shared/" \ || exit -1 rm "$directory_name" || exit -1 diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index a88f9642c..03828f54f 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -12,7 +12,7 @@ let config: IConfig = require('config') // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 185 +const LAST_MIGRATION_VERSION = 190 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0190-video-comment-unique-url.ts b/server/initializers/migrations/0190-video-comment-unique-url.ts new file mode 100644 index 000000000..b196c9352 --- /dev/null +++ b/server/initializers/migrations/0190-video-comment-unique-url.ts @@ -0,0 +1,23 @@ +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/support/doc/production.md b/support/doc/production.md index 56d00bf56..6bf6c1ca3 100644 --- a/support/doc/production.md +++ b/support/doc/production.md @@ -280,28 +280,29 @@ $ cd /var/www/peertube/versions && \ sudo -u peertube rm peertube-${VERSION}.zip ``` -Change the link to point to the latest version: +Install node dependencies: ``` -$ cd /var/www/peertube && \ - sudo rm ./peertube-latest && \ - sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest +$ cd /var/www/peertube/versions/peertube-${VERSION} && \ + sudo -u peertube yarn install --production --pure-lockfile ``` -Install node dependencies: +Copy new configuration defaults values and update your configuration file: ``` -$ cd /var/www/peertube/peertube-latest && \ - sudo -u peertube yarn install --production --pure-lockfile +$ sudo -u peertube cp /var/www/peertube/versions/peertube-${VERSION}/config/default.yaml /var/www/peertube/config/default.yaml +$ diff /var/www/peertube/versions/peertube-${VERSION}/config//production.yaml.example /var/www/peertube/config/production.yaml ``` -Copy new configuration defaults values and update your configuration file: +Change the link to point to the latest version: ``` -$ sudo -u peertube cp /var/www/peertube/peertube-latest/config/default.yaml /var/www/peertube/config/default.yaml -$ diff /var/www/peertube/peertube-latest/config//production.yaml.example /var/www/peertube/config/production.yaml +$ cd /var/www/peertube && \ + sudo rm ./peertube-latest && \ + sudo -u peertube ln -s versions/peertube-${VERSION} ./peertube-latest ``` + Restart PeerTube: ``` $ sudo systemctl restart peertube -- 2.25.1