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