Skip to content

Commit 5019a34

Browse files
committed
The fix
1 parent 0589d26 commit 5019a34

File tree

7 files changed

+17556
-1309
lines changed

7 files changed

+17556
-1309
lines changed

backend/typescript/.sequelizerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
// @ts-nocheck
12
const path = require('path');
2-
33
module.exports = {
44
'config': path.resolve('config', 'config.js'),
55
'models-path': path.resolve('models'),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require('dotenv').config();
2+
3+
4+
const common = {
5+
dialect: process.env.DB_DIALECT || 'postgres',
6+
host: process.env.DB_HOST || 'db', // name of the DB service in docker-compose
7+
port: Number(process.env.POSTGRES_DB_PORT || 5432),
8+
username: process.env.POSTGRES_USER || 'postgres',
9+
password: process.env.POSTGRES_PASSWORD || 'postgres',
10+
database: process.env.POSTGRES_DB_DEV || 'humane_society_dev',
11+
logging: false,
12+
define: {
13+
underscored: true, // set true if your tables/columns use snake_case
14+
freezeTableName: false
15+
}
16+
};
17+
18+
module.exports = {
19+
development: common,
20+
test: { ...common, database: process.env.POSTGRES_DB_TEST || `${common.database}_test` },
21+
production: { ...common, logging: false }
22+
};
Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Migration } from "../umzug";
1+
// import { Migration } from "../umzug";
2+
import { QueryInterface } from "sequelize";
23

34
const OLD_TASKS_TABLE = "activities";
45
const NEW_TASKS_TABLE = "tasks";
@@ -10,63 +11,55 @@ const NEW_ID_COL = "task_template_id";
1011
const OLD_TASK_NAME = "activity_name";
1112
const NEW_TASK_NAME = "task_name";
1213

13-
export const up: Migration = async ({ context: sequelize }) => {
14-
const queryinterface = sequelize.getQueryInterface();
14+
module.exports = {
15+
up: async (queryInterface: QueryInterface, Sequelize: any) => {
1516

16-
await queryinterface.renameTable(
17+
await queryInterface.renameTable(
1718
// rename activities table to tasks
1819
OLD_TASKS_TABLE,
1920
NEW_TASKS_TABLE,
2021
);
2122

22-
await queryinterface.renameTable(
23+
await queryInterface.renameTable(
2324
// rename activitytypes to task templates
2425
OLD_TASKTEMPLATES_TABLE,
2526
NEW_TASKTEMPLATES_TABLE,
2627
);
2728

28-
await queryinterface.renameColumn(
29+
await queryInterface.renameColumn(
2930
// rename activity type id to task type id
3031
NEW_TASKS_TABLE,
3132
OLD_ID_COL,
3233
NEW_ID_COL,
3334
);
3435

35-
await queryinterface.renameColumn(
36+
await queryInterface.renameColumn(
3637
// rename activity name to task name
3738
NEW_TASKTEMPLATES_TABLE,
3839
OLD_TASK_NAME,
3940
NEW_TASK_NAME,
4041
);
41-
};
42-
43-
export const down: Migration = async ({ context: sequelize }) => {
44-
// reverts migration
45-
const queryinterface = sequelize.getQueryInterface();
46-
47-
await queryinterface.renameColumn(
48-
// rename task name to activity name
49-
NEW_TASKTEMPLATES_TABLE,
50-
NEW_TASK_NAME,
51-
OLD_TASK_NAME,
52-
);
5342

54-
await queryinterface.renameColumn(
43+
},
44+
down: async (queryInterface: QueryInterface, Sequelize: any) => {
45+
46+
await queryInterface.renameColumn(
5547
// rename taskid back to activityid col
5648
NEW_TASKS_TABLE,
5749
NEW_ID_COL,
5850
OLD_ID_COL,
5951
);
6052

61-
await queryinterface.renameTable(
53+
await queryInterface.renameTable(
6254
// rename tasktemplate table back to activity types
6355
NEW_TASKTEMPLATES_TABLE,
6456
OLD_TASKTEMPLATES_TABLE,
6557
);
6658

67-
await queryinterface.renameTable(
59+
await queryInterface.renameTable(
6860
// rename tasks table back to activites
6961
NEW_TASKS_TABLE,
7062
OLD_TASKS_TABLE,
7163
);
64+
},
7265
};

0 commit comments

Comments
 (0)