Skip to content

Commit 7e65248

Browse files
cleaner code
1 parent 66512f0 commit 7e65248

File tree

1 file changed

+16
-50
lines changed

1 file changed

+16
-50
lines changed

backend/typescript/migrations/20250705172630-delete-bad-seeded-user-data.ts

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -37,57 +37,23 @@ const PREVIOUS_USER_SEED_DATA = [
3737
];
3838

3939
export const up: Migration = async ({ context: sequelize }) => {
40-
// update malformed users with id 1 and 2 with proper seeded data
41-
await sequelize.getQueryInterface().bulkUpdate(
42-
"users",
43-
{
44-
first_name: USER_SEED_DATA[0].first_name,
45-
last_name: USER_SEED_DATA[0].last_name,
46-
email: USER_SEED_DATA[0].email,
47-
auth_id: USER_SEED_DATA[0].auth_id,
48-
role: USER_SEED_DATA[0].role,
49-
position: USER_SEED_DATA[0].position,
50-
},
51-
{ id: 1 },
52-
);
53-
54-
await sequelize.getQueryInterface().bulkUpdate(
55-
"users",
56-
{
57-
first_name: USER_SEED_DATA[1].first_name,
58-
last_name: USER_SEED_DATA[1].last_name,
59-
email: USER_SEED_DATA[1].email,
60-
auth_id: USER_SEED_DATA[1].auth_id,
61-
role: USER_SEED_DATA[1].role,
62-
position: USER_SEED_DATA[1].position,
63-
},
64-
{ id: 2 },
65-
);
40+
// Update user with id 1
41+
await sequelize
42+
.getQueryInterface()
43+
.bulkUpdate("users", USER_SEED_DATA[0], { id: 1 });
44+
// Update user with id 2
45+
await sequelize
46+
.getQueryInterface()
47+
.bulkUpdate("users", USER_SEED_DATA[1], { id: 2 });
6648
};
6749

6850
export const down: Migration = async ({ context: sequelize }) => {
69-
// update malformed users with id 1 and 2 with proper seeded data
70-
await sequelize.getQueryInterface().bulkUpdate(
71-
"users",
72-
{
73-
first_name: PREVIOUS_USER_SEED_DATA[1].first_name,
74-
last_name: PREVIOUS_USER_SEED_DATA[1].last_name,
75-
email: PREVIOUS_USER_SEED_DATA[1].email,
76-
auth_id: PREVIOUS_USER_SEED_DATA[1].auth_id,
77-
role: PREVIOUS_USER_SEED_DATA[1].role,
78-
},
79-
{ id: 2 },
80-
);
81-
82-
await sequelize.getQueryInterface().bulkUpdate(
83-
"users",
84-
{
85-
first_name: PREVIOUS_USER_SEED_DATA[0].first_name,
86-
last_name: PREVIOUS_USER_SEED_DATA[0].last_name,
87-
email: PREVIOUS_USER_SEED_DATA[0].email,
88-
auth_id: PREVIOUS_USER_SEED_DATA[0].auth_id,
89-
role: PREVIOUS_USER_SEED_DATA[0].role,
90-
},
91-
{ id: 1 },
92-
);
51+
// Revert user with id 1
52+
await sequelize
53+
.getQueryInterface()
54+
.bulkUpdate("users", PREVIOUS_USER_SEED_DATA[0], { id: 1 });
55+
// Revert user with id 2
56+
await sequelize
57+
.getQueryInterface()
58+
.bulkUpdate("users", PREVIOUS_USER_SEED_DATA[1], { id: 2 });
9359
};

0 commit comments

Comments
 (0)