0235-delete-some-video-indexes.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. await utils.sequelize.query('DROP INDEX IF EXISTS video_id_privacy_state_wait_transcoding;')
  8. await utils.sequelize.query('DROP INDEX IF EXISTS video_name;')
  9. for (let i = 0; i < 5; i++) {
  10. const query = 'DELETE FROM "videoFile" WHERE id IN ' +
  11. '(SELECT id FROM (SELECT MIN(id) AS id, "videoId", "resolution", "fps" ' +
  12. 'FROM "videoFile" GROUP BY "videoId", "resolution", "fps" HAVING COUNT(*) > 1) t)'
  13. await utils.sequelize.query(query)
  14. }
  15. for (let i = 0; i < 5; i++) {
  16. const query = 'DELETE FROM "actor" WHERE id IN ' +
  17. '(SELECT id FROM (SELECT MIN(id) AS id, "uuid" ' +
  18. 'FROM "actor" GROUP BY "uuid" HAVING COUNT(*) > 1) t)'
  19. await utils.sequelize.query(query)
  20. }
  21. for (let i = 0; i < 5; i++) {
  22. const query = 'DELETE FROM "account" WHERE id IN ' +
  23. '(SELECT id FROM (SELECT MIN(id) AS id, "actorId" ' +
  24. 'FROM "account" GROUP BY "actorId" HAVING COUNT(*) > 1) t)'
  25. await utils.sequelize.query(query)
  26. }
  27. }
  28. function down (options) {
  29. throw new Error('Not implemented.')
  30. }
  31. export { up, down }