Skip to content

Commit

Permalink
Merge pull request #75 from SAMAHAN-Systems-Development/hotfix/add-de…
Browse files Browse the repository at this point in the history
…partment-name-to-event

fix(event): add department_name field to Event model
  • Loading branch information
SaaammmyyyS authored Oct 31, 2024
2 parents c705942 + 97c82ab commit 7d27a08
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
Warnings:
- Added the required column `department_name` to the `Event` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Event" ADD COLUMN "department_name" TEXT NOT NULL;
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ model Event {
location Location @relation(fields: [location_id], references: [id])
posters Poster[]
thumbnail String
department_name String
}

model Poster {
Expand Down
9 changes: 9 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,14 @@ async function seedEvents() {
'https://forms.gle/6DM4nj6EikNLF6rKA',
];

const departmentNames = [
'SAMAHAN',
'University Library',
'Theology Department, School of Arts and Sciences',
'Career Center Office',
'Ateneo de Davao - Language Center',
];

const events = eventNames.map((name, index) => {
const startTime = faker.date.future();
const endTime = new Date(startTime.getTime() + 24 * 60 * 60 * 1000);
Expand All @@ -213,6 +221,7 @@ async function seedEvents() {
created_at: new Date(),
updated_at: new Date(),
thumbnail: faker.image.url(),
department_name: departmentNames[index],
};
});

Expand Down
4 changes: 4 additions & 0 deletions src/event/create-event.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ export class CreateEventDto {
@IsNotEmpty()
@Transform(({ value }) => Number(value))
location_id: number;

@IsString()
@IsNotEmpty()
department_name: string;
}
4 changes: 4 additions & 0 deletions src/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export class EventService {
const {
name,
email,
department_name,
description,
registration_link,
start_time,
Expand Down Expand Up @@ -77,6 +78,7 @@ export class EventService {
data: {
name,
email,
department_name,
description,
registration_link,
start_time: new Date(start_time),
Expand Down Expand Up @@ -144,6 +146,7 @@ export class EventService {
const {
name,
email,
department_name,
description,
registration_link,
start_time,
Expand Down Expand Up @@ -173,6 +176,7 @@ export class EventService {
data: {
name,
email,
department_name,
description,
registration_link,
start_time: new Date(start_time),
Expand Down

0 comments on commit 7d27a08

Please sign in to comment.