From 0bcd180448a9bede293fb1392314b1d4c6d5c517 Mon Sep 17 00:00:00 2001 From: solvhold Date: Mon, 20 Oct 2025 17:11:51 +0200 Subject: [PATCH 1/4] feat: :card_file_box: add connection between semesters and applications vf-329 --- db/tables/applications.ts | 10 +++++++++- db/tables/semesters.ts | 2 ++ src/db-access/applications.ts | 4 ++++ src/request-handling/applications.ts | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/db/tables/applications.ts b/db/tables/applications.ts index 264868c..e5ebe5f 100644 --- a/db/tables/applications.ts +++ b/db/tables/applications.ts @@ -12,6 +12,7 @@ import { import { teamsTable } from "@/db/tables/teams"; import { fieldsOfStudyTable } from "./fields-of-study"; import { interviewsTable } from "./interviews"; +import { semestersTable } from "./semesters"; export const gendersEnum = mainSchema.enum("gender", [ "female", @@ -30,6 +31,9 @@ export const applicationsTable = mainSchema.table("applications", { .references(() => fieldsOfStudyTable.id), yearOfStudy: integer("yearOfStudy").notNull(), phonenumber: text("phonenumber").notNull(), + semester: integer("semester") + .notNull() + .references(() => semestersTable.id), submitDate: date("submitDate", { mode: "date" }).defaultNow().notNull(), }); @@ -40,12 +44,16 @@ export const applicationsRelations = relations( fields: [applicationsTable.fieldOfStudyId], references: [fieldsOfStudyTable.id], }), + semesters: one(semestersTable, { + fields: [applicationsTable.semester], + references: [semestersTable.id], + }), assistantApplication: one(assistantApplicationsTable, { fields: [applicationsTable.id], references: [assistantApplicationsTable.id], }), teamApplication: many(teamApplicationsTable), - interview: many(interviewsTable), + }), ); diff --git a/db/tables/semesters.ts b/db/tables/semesters.ts index dc9e824..d93d61c 100644 --- a/db/tables/semesters.ts +++ b/db/tables/semesters.ts @@ -10,6 +10,7 @@ import { departmentsTable } from "./departments"; import { mainSchema } from "./schema"; import { schoolSemesterAssistantsTable } from "./school-semester-assistant"; import { teamSemesterUsersTable } from "./team-semester-user"; +import { applicationsTable } from "./applications"; export const semestersTable = mainSchema.table("semesters", { id: serial("id").primaryKey(), @@ -43,5 +44,6 @@ export const semestersRelations = relations( }), schoolAssistants: many(schoolSemesterAssistantsTable), teamUsers: many(teamSemesterUsersTable), + applications: many(applicationsTable), }), ); diff --git a/src/db-access/applications.ts b/src/db-access/applications.ts index 2fa95b2..328a731 100644 --- a/src/db-access/applications.ts +++ b/src/db-access/applications.ts @@ -37,6 +37,7 @@ export const selectTeamApplications = async ( motivationText: teamApplicationsTable.motivationText, biography: teamApplicationsTable.biography, teamInterest: teamApplicationsTable.teamInterest, + semester: applicationsTable.semester, submitDate: applicationsTable.submitDate, }) .from(teamApplicationsTable) @@ -71,6 +72,7 @@ export const selectTeamApplicationsByTeamId = async ( motivationText: teamApplicationsTable.motivationText, biography: teamApplicationsTable.biography, teamInterest: teamApplicationsTable.teamInterest, + semester: applicationsTable.semester, submitDate: applicationsTable.submitDate, }) .from(teamApplicationsTable) @@ -106,6 +108,7 @@ export const selectTeamApplicationsById = async ( motivationText: teamApplicationsTable.motivationText, biography: teamApplicationsTable.biography, teamInterest: teamApplicationsTable.teamInterest, + semester: applicationsTable.semester, submitDate: applicationsTable.submitDate, }) .from(teamApplicationsTable) @@ -138,6 +141,7 @@ export async function insertTeamApplication( fieldOfStudyId: teamApplication.fieldOfStudyId, yearOfStudy: teamApplication.yearOfStudy, phonenumber: teamApplication.phonenumber, + semester: teamApplication.semester, }) .returning(); const newApplicationId = newApplication[0].id; diff --git a/src/request-handling/applications.ts b/src/request-handling/applications.ts index 101c6e2..832db7a 100644 --- a/src/request-handling/applications.ts +++ b/src/request-handling/applications.ts @@ -37,6 +37,9 @@ export const applicationParser = z .string() .regex(/^\d{8}$/, "Phone number must be 8 digits") .describe("The phonenumber of the user applying for a team"), + semester: serialIdParser.describe( + "The semester the application is for", + ), }) .strict(); From 0ee618764dc1014499ab82af6a7af19e70fe22b8 Mon Sep 17 00:00:00 2001 From: solvhold Date: Mon, 20 Oct 2025 17:17:28 +0200 Subject: [PATCH 2/4] refactor: :art: run pnpm check vf-329 --- db/tables/applications.ts | 1 - db/tables/semesters.ts | 2 +- src/request-handling/applications.ts | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/db/tables/applications.ts b/db/tables/applications.ts index e5ebe5f..f8a39dc 100644 --- a/db/tables/applications.ts +++ b/db/tables/applications.ts @@ -53,7 +53,6 @@ export const applicationsRelations = relations( references: [assistantApplicationsTable.id], }), teamApplication: many(teamApplicationsTable), - }), ); diff --git a/db/tables/semesters.ts b/db/tables/semesters.ts index d93d61c..c0128ff 100644 --- a/db/tables/semesters.ts +++ b/db/tables/semesters.ts @@ -6,11 +6,11 @@ import { serial, text, } from "drizzle-orm/pg-core"; +import { applicationsTable } from "./applications"; import { departmentsTable } from "./departments"; import { mainSchema } from "./schema"; import { schoolSemesterAssistantsTable } from "./school-semester-assistant"; import { teamSemesterUsersTable } from "./team-semester-user"; -import { applicationsTable } from "./applications"; export const semestersTable = mainSchema.table("semesters", { id: serial("id").primaryKey(), diff --git a/src/request-handling/applications.ts b/src/request-handling/applications.ts index 832db7a..a3df681 100644 --- a/src/request-handling/applications.ts +++ b/src/request-handling/applications.ts @@ -37,9 +37,7 @@ export const applicationParser = z .string() .regex(/^\d{8}$/, "Phone number must be 8 digits") .describe("The phonenumber of the user applying for a team"), - semester: serialIdParser.describe( - "The semester the application is for", - ), + semester: serialIdParser.describe("The semester the application is for"), }) .strict(); From 4324b1f346b100a5ad571370f242db5e1f796f4b Mon Sep 17 00:00:00 2001 From: solvhold Date: Mon, 10 Nov 2025 17:46:37 +0100 Subject: [PATCH 3/4] fix: create critical fix vf-329 --- db/seeding/seeding-tables.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/db/seeding/seeding-tables.ts b/db/seeding/seeding-tables.ts index e7340c5..a2bfc63 100644 --- a/db/seeding/seeding-tables.ts +++ b/db/seeding/seeding-tables.ts @@ -6,11 +6,10 @@ import { teamsTable } from "@/db/tables/teams"; import { usersTable } from "@/db/tables/users"; export const seedingTables = { - departmentsTable, - fieldsOfStudyTable, - teamsTable, - usersTable, - // meetings, + //departmentsTable, + //fieldsOfStudyTable, + //teamsTable, + //usersTable, //teamUsersTable, these two tables dont work currently //assistantUsersTable, //teamApplicationsTable, From 7d9ccaf312b8d8c30cbddc7c49717ac8618bfa66 Mon Sep 17 00:00:00 2001 From: solvhold Date: Mon, 10 Nov 2025 18:14:04 +0100 Subject: [PATCH 4/4] fix: fix critical fix vf-329 --- db/seeding/seeding-tables.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeding/seeding-tables.ts b/db/seeding/seeding-tables.ts index a2bfc63..9b3571e 100644 --- a/db/seeding/seeding-tables.ts +++ b/db/seeding/seeding-tables.ts @@ -13,8 +13,8 @@ export const seedingTables = { //teamUsersTable, these two tables dont work currently //assistantUsersTable, //teamApplicationsTable, - expensesTable, - applicationsTable, + //expensesTable, + //applicationsTable, // meetingsTable, // schoolsTable };