2
1

0095-videos-privacy.ts 724 B

1234567891011121314151617181920212223242526272829303132333435
  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 q = utils.queryInterface
  9. const data = {
  10. type: Sequelize.INTEGER,
  11. defaultValue: null,
  12. allowNull: true
  13. }
  14. await q.addColumn('Videos', 'privacy', data)
  15. const query = 'UPDATE "Videos" SET "privacy" = 1'
  16. const options = {
  17. type: Sequelize.QueryTypes.BULKUPDATE
  18. }
  19. await utils.sequelize.query(query, options)
  20. data.allowNull = false
  21. await q.changeColumn('Videos', 'privacy', data)
  22. }
  23. function down (options) {
  24. throw new Error('Not implemented.')
  25. }
  26. export {
  27. up,
  28. down
  29. }