2
1

0005-email-pod.ts 858 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import * as Sequelize from 'sequelize'
  2. import * as Promise from 'bluebird'
  3. import { Migration } from '../../models/migrations'
  4. function up (utils: {
  5. transaction: Sequelize.Transaction,
  6. queryInterface: Sequelize.QueryInterface,
  7. sequelize: Sequelize.Sequelize
  8. }): Promise<void> {
  9. const q = utils.queryInterface
  10. const data = {
  11. type: Sequelize.STRING(400),
  12. allowNull: false,
  13. defaultValue: ''
  14. } as Migration.String
  15. return q.addColumn('Pods', 'email', data)
  16. .then(() => {
  17. const query = 'UPDATE "Pods" SET "email" = \'dummy@example.com\''
  18. return utils.sequelize.query(query, { transaction: utils.transaction })
  19. })
  20. .then(() => {
  21. data.defaultValue = null
  22. return q.changeColumn('Pods', 'email', data)
  23. })
  24. }
  25. function down (options) {
  26. throw new Error('Not implemented.')
  27. }
  28. export {
  29. up,
  30. down
  31. }