From d6aaab28f7606be519935de0d21fb76c0c1a937c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Jan 2018 14:51:05 +0100 Subject: [PATCH] Remove :443 from video urls too --- server/initializers/constants.ts | 2 +- .../migrations/0165-video-route.ts | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 server/initializers/migrations/0165-video-route.ts diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index f8e6b52d7..c902e0cf6 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -9,7 +9,7 @@ import { isTestInstance, root, sanitizeHost, sanitizeUrl } from '../helpers/core // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 160 +const LAST_MIGRATION_VERSION = 165 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0165-video-route.ts b/server/initializers/migrations/0165-video-route.ts new file mode 100644 index 000000000..56d98bc69 --- /dev/null +++ b/server/initializers/migrations/0165-video-route.ts @@ -0,0 +1,25 @@ +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 +} -- 2.41.0