Remove :443 from video urls too
authorChocobozzz <me@florianbigard.com>
Fri, 5 Jan 2018 13:51:05 +0000 (14:51 +0100)
committerChocobozzz <me@florianbigard.com>
Fri, 5 Jan 2018 13:51:05 +0000 (14:51 +0100)
server/initializers/constants.ts
server/initializers/migrations/0165-video-route.ts [new file with mode: 0644]

index f8e6b52d7a77adacbdd7356047cb2f7157310279..c902e0cf69fdde0314a3c77a477cd31bd116385d 100644 (file)
@@ -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 (file)
index 0000000..56d98bc
--- /dev/null
@@ -0,0 +1,25 @@
+import * as Sequelize from 'sequelize'
+
+async function up (utils: {
+  transaction: Sequelize.Transaction,
+  queryInterface: Sequelize.QueryInterface,
+  sequelize: Sequelize.Sequelize
+}): Promise<void> {
+  {
+    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
+}