0140-actor-url.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import * as Sequelize from 'sequelize'
  2. import { WEBSERVER } from '../constants'
  3. async function up (utils: {
  4. transaction: Sequelize.Transaction,
  5. queryInterface: Sequelize.QueryInterface,
  6. sequelize: Sequelize.Sequelize
  7. }): Promise<void> {
  8. const toReplace = WEBSERVER.HOSTNAME + ':443'
  9. const by = WEBSERVER.HOST
  10. const replacer = column => `replace("${column}", '${toReplace}', '${by}')`
  11. {
  12. const query = `UPDATE video SET url = ${replacer('url')}`
  13. await utils.sequelize.query(query)
  14. }
  15. {
  16. const query = `
  17. UPDATE actor SET url = ${replacer('url')}, "inboxUrl" = ${replacer('inboxUrl')}, "outboxUrl" = ${replacer('outboxUrl')},
  18. "sharedInboxUrl" = ${replacer('sharedInboxUrl')}, "followersUrl" = ${replacer('followersUrl')},
  19. "followingUrl" = ${replacer('followingUrl')}
  20. `
  21. await utils.sequelize.query(query)
  22. }
  23. {
  24. const query = `UPDATE server SET host = replace(host, ':443', '')`
  25. await utils.sequelize.query(query)
  26. }
  27. }
  28. function down (options) {
  29. throw new Error('Not implemented.')
  30. }
  31. export {
  32. up,
  33. down
  34. }