Skip to content

Commit 06b52cd

Browse files
jeesshMaggie Chen
authored andcommitted
fixed migrations + moved to utils folder
1 parent 0bfc3bc commit 06b52cd

File tree

5 files changed

+5716
-24
lines changed

5 files changed

+5716
-24
lines changed

backend/typescript/migrations/2025.07.21T07.02.41.create-applicants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DataType } from "sequelize-typescript";
22
import { v4 as uuidv4 } from "uuid";
33
import { Migration } from "../umzug";
4-
import applicants from "./separateJSONs";
4+
import applicants from "./processedApplicants.json";
55

66
const TABLE_NAME = "applicants";
77

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { DataType } from "sequelize-typescript";
2+
import { v4 as uuidv4 } from "uuid";
3+
import { Migration } from "../umzug";
4+
import {
5+
Department,
6+
PositionTitles,
7+
EngineeringPositionTitles,
8+
DesignPositionTitles,
9+
ProductPositionTitles,
10+
CommunityPositionTitles,
11+
} from "../types";
12+
13+
const TABLE_NAME = "positions";
14+
15+
const SEEDED_DATA = [
16+
...EngineeringPositionTitles.map((title) => ({
17+
title,
18+
department: Department.Engineering,
19+
})),
20+
21+
...DesignPositionTitles.map((title) => ({
22+
title,
23+
department: Department.Design,
24+
})),
25+
26+
...ProductPositionTitles.map((title) => ({
27+
title,
28+
department: Department.Product,
29+
})),
30+
31+
...CommunityPositionTitles.map((title) => ({
32+
title,
33+
department: Department.Community,
34+
})),
35+
];
36+
37+
export const up: Migration = async ({ context: sequelize }) => {
38+
await sequelize.getQueryInterface().createTable(TABLE_NAME, {
39+
title: {
40+
type: DataType.ENUM(...PositionTitles),
41+
allowNull: false,
42+
primaryKey: true,
43+
},
44+
department: {
45+
type: DataType.ENUM(...Object.values(Department)),
46+
allowNull: false,
47+
},
48+
});
49+
50+
await sequelize.query("DELETE FROM positions");
51+
52+
await sequelize.getQueryInterface().bulkInsert(TABLE_NAME, SEEDED_DATA);
53+
};
54+
55+
export const down: Migration = async ({ context: sequelize }) => {
56+
await sequelize.getQueryInterface().dropTable(TABLE_NAME);
57+
};

backend/typescript/migrations/2025.07.21T15.30.15.create-applicant-record.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { v4 as uuidv4 } from "uuid";
33
import { Migration } from "../umzug";
44

55
import allApplications from "./applicationlist.json";
6-
import applicants from "./separateJSONs";
6+
import applicants from "./processedApplicants.json";
77
import {
88
ApplicationStatus,
99
SkillCategory,
@@ -113,7 +113,7 @@ export const up: Migration = async ({ context: sequelize }) => {
113113
},
114114
},
115115
position: {
116-
type: DataType.STRING,
116+
type: DataType.ENUM(...ALL_POSITION_TITLES),
117117
allowNull: true,
118118
references: {
119119
model: "positions",

0 commit comments

Comments
 (0)