0245-user-blocked.ts 944 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. {
  8. const data = {
  9. type: Sequelize.BOOLEAN,
  10. allowNull: true,
  11. defaultValue: null
  12. }
  13. await utils.queryInterface.addColumn('user', 'blocked', data)
  14. }
  15. {
  16. const query = 'UPDATE "user" SET "blocked" = false'
  17. await utils.sequelize.query(query)
  18. }
  19. {
  20. const data = {
  21. type: Sequelize.BOOLEAN,
  22. allowNull: false,
  23. defaultValue: null
  24. }
  25. await utils.queryInterface.changeColumn('user', 'blocked', data)
  26. }
  27. {
  28. const data = {
  29. type: Sequelize.STRING(250),
  30. allowNull: true,
  31. defaultValue: null
  32. }
  33. await utils.queryInterface.addColumn('user', 'blockedReason', data)
  34. }
  35. }
  36. function down (options) {
  37. throw new Error('Not implemented.')
  38. }
  39. export { up, down }