Skip to content

Commit 5619d28

Browse files
Merge pull request #61 from uwblueprint/INTS25_delete_bad_seeded_data
[INTS25] - create migration file to modify bad seeded user data
2 parents 3762776 + 7e65248 commit 5619d28

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { Migration } from "../umzug";
2+
3+
const USER_SEED_DATA = [
4+
{
5+
first_name: "Carolyn",
6+
last_name: "Zhang",
7+
email: "carolynzhang@uwblueprint.org",
8+
auth_id: "ATd5GMzp8IPJzQzuQYkaavcelb32",
9+
role: "Admin",
10+
position: "VP Engineering",
11+
},
12+
{
13+
first_name: "Jesse",
14+
last_name: "Huang",
15+
email: "jessehuang@uwblueprint.org",
16+
auth_id: "dkXIhkZXljOuEsXrZDASEguCQw43",
17+
role: "Admin",
18+
position: "VP Engineering",
19+
},
20+
];
21+
22+
const PREVIOUS_USER_SEED_DATA = [
23+
{
24+
first_name: "John",
25+
last_name: "Doe",
26+
email: "johndoe@gmail.com",
27+
auth_id: "bide",
28+
role: "User",
29+
},
30+
{
31+
first_name: "Jane",
32+
last_name: "Doe",
33+
email: "janedoe@gmail.ca",
34+
auth_id: "none",
35+
role: "Admin",
36+
},
37+
];
38+
39+
export const up: Migration = async ({ context: sequelize }) => {
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 });
48+
};
49+
50+
export const down: Migration = async ({ context: sequelize }) => {
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 });
59+
};

0 commit comments

Comments
 (0)