ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

28 lines
653 B

  1. import * as Sequelize from 'sequelize'
  2. async function up (utils: {
  3. transaction: Sequelize.Transaction
  4. queryInterface: Sequelize.QueryInterface
  5. sequelize: Sequelize.Sequelize
  6. db: any
  7. }): Promise<void> {
  8. const { transaction } = utils
  9. const query = 'DELETE FROM "localVideoViewer" t1 ' +
  10. 'USING (SELECT MIN(id) as id, "url" FROM "localVideoViewer" GROUP BY "url" HAVING COUNT(*) > 1) t2 ' +
  11. 'WHERE t1."url" = t2."url" AND t1.id <> t2.id'
  12. await utils.sequelize.query(query, { transaction })
  13. }
  14. async function down (utils: {
  15. queryInterface: Sequelize.QueryInterface
  16. transaction: Sequelize.Transaction
  17. }) {
  18. }
  19. export {
  20. up,
  21. down
  22. }