Skip to content

Commit 6ffd9fb

Browse files
committed
Tweak names in migration
Pass the type instead of the whole field object. Prettier and eslint nonsense.
1 parent b3c9c54 commit 6ffd9fb

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

migrations/20220721055200-add-gcs-treatments-to-patient.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,28 @@
1+
/* eslint-disable no-await-in-loop, no-restricted-syntax */
12
const patient = require('../src/metadata/patient');
23
const convertToSequelizeField = require('../src/metadata/convertToSequelizeField');
34

45
const fields = patient.getFieldHash(convertToSequelizeField);
5-
const newFields = ['treatmentNotes', 'glasgowComaScale'];
6+
const newFieldNames = ['treatmentNotes', 'glasgowComaScale'];
67
const { tableName } = patient;
78

89
module.exports = {
9-
up: async (queryInterface, Sequelize) => {
10+
async up(queryInterface, Sequelize) {
1011
await queryInterface.sequelize.transaction(async (transaction) => {
11-
for (const fieldName of newFields) {
12-
const newField = fields[fieldName];
12+
for (const name of newFieldNames) {
13+
const { field, type } = fields[name];
1314

14-
await queryInterface.addColumn(
15-
tableName,
16-
newField.field,
17-
newField,
18-
{ transaction }
19-
);
15+
await queryInterface.addColumn(tableName, field, type, { transaction });
2016
}
2117
});
2218
},
2319

24-
down: async (queryInterface) => {
20+
async down(queryInterface) {
2521
await queryInterface.sequelize.transaction(async (transaction) => {
26-
for (const fieldName of newFields) {
27-
const newField = fields[fieldName];
22+
for (const name of newFieldNames) {
23+
const { field } = fields[name];
2824

29-
await queryInterface.removeColumn(tableName, newField.field, { transaction });
25+
await queryInterface.removeColumn(tableName, field, { transaction });
3026
}
3127
});
3228
},

0 commit comments

Comments
 (0)