0160-account-route.ts 1.2 KB

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