aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r--server/initializers/migrations/0140-actor-url.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/server/initializers/migrations/0140-actor-url.ts b/server/initializers/migrations/0140-actor-url.ts
new file mode 100644
index 000000000..626f3c444
--- /dev/null
+++ b/server/initializers/migrations/0140-actor-url.ts
@@ -0,0 +1,42 @@
1import * as Sequelize from 'sequelize'
2import { DataType } from 'sequelize-typescript'
3import { createPrivateAndPublicKeys } from '../../helpers'
4import { CONFIG } from '../constants'
5
6async function up (utils: {
7 transaction: Sequelize.Transaction,
8 queryInterface: Sequelize.QueryInterface,
9 sequelize: Sequelize.Sequelize
10}): Promise<void> {
11 const toReplace = CONFIG.WEBSERVER.HOSTNAME + ':443'
12 const by = CONFIG.WEBSERVER.HOST
13 const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
14
15 {
16 const query = `UPDATE video SET url = ${replacer('url')}`
17 await utils.sequelize.query(query)
18 }
19
20 {
21 const query = `
22 UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')},
23 "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')},
24 "followingUrl" = ${replacer('followingUrl')}
25 `
26 await utils.sequelize.query(query)
27 }
28
29 {
30 const query = `UPDATE server SET host = replace(host, ':443', '')`
31 await utils.sequelize.query(query)
32 }
33}
34
35function down (options) {
36 throw new Error('Not implemented.')
37}
38
39export {
40 up,
41 down
42}