0240-drop-old-indexes.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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<any> {
  7. const indexNames = [
  8. 'accounts_application_id',
  9. 'accounts_user_id',
  10. 'accounts_name',
  11. 'account_video_rates_video_id_account_id',
  12. 'account_video_rates_video_id_account_id_type',
  13. 'account_follows_account_id_target_account_id',
  14. 'account_follow_account_id_target_account_id',
  15. 'account_follow_account_id',
  16. 'account_follow_target_account_id',
  17. 'account_follows_account_id',
  18. 'account_follows_target_account_id',
  19. 'o_auth_clients_client_id',
  20. 'o_auth_clients_client_id_client_secret',
  21. 'o_auth_tokens_access_token',
  22. 'o_auth_tokens_refresh_token',
  23. 'o_auth_tokens_o_auth_client_id',
  24. 'o_auth_tokens_user_id',
  25. 'pods_host',
  26. 'servers_host',
  27. 'tags_name',
  28. 'users_email',
  29. 'users_username',
  30. 'videos_channel_id',
  31. 'videos_created_at',
  32. 'videos_duration',
  33. 'videos_likes',
  34. 'videos_name',
  35. 'videos_uuid',
  36. 'videos_views',
  37. 'video_abuses_reporter_account_id',
  38. 'video_abuses_video_id',
  39. 'blacklisted_videos_video_id',
  40. 'video_channels_account_id',
  41. 'video_files_info_hash',
  42. 'video_files_video_id',
  43. 'video_shares_account_id',
  44. 'video_shares_video_id',
  45. 'video_tags_tag_id',
  46. 'video_tags_video_id'
  47. ]
  48. for (const indexName of indexNames) {
  49. await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";')
  50. }
  51. await utils.sequelize.query('ALTER TABLE "account" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";')
  52. await utils.sequelize.query('ALTER TABLE "videoChannel" DROP CONSTRAINT IF EXISTS "actorId_foreign_idx";')
  53. await utils.sequelize.query('ALTER TABLE "videoShare" DROP CONSTRAINT IF EXISTS "VideoShares_videoId_fkey";')
  54. await utils.sequelize.query('DROP TABLE IF EXISTS "videoChannelShare";')
  55. }
  56. function down (options) {
  57. throw new Error('Not implemented.')
  58. }
  59. export { up, down }