ニジカ投稿局 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.
 
 
 
 
 

25 lines
580 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. }): Promise<void> {
  7. const { transaction } = utils
  8. const query = 'DELETE FROM "runner" r1 ' +
  9. 'USING (SELECT MIN(id) as id, "name" FROM "runner" GROUP BY "name" HAVING COUNT(*) > 1) r2 ' +
  10. 'WHERE r1."name" = r2."name" AND r1.id <> r2.id'
  11. await utils.sequelize.query(query, { transaction })
  12. }
  13. function down (options) {
  14. throw new Error('Not implemented.')
  15. }
  16. export {
  17. up,
  18. down
  19. }