Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
527 changes: 527 additions & 0 deletions backend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"express-session": "^1.18.1",
"pg": "^8.10.0",
"prisma": "^6.0.1",
"psql": "^0.0.1",
"zod": "^3.22.4"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- CreateEnum
CREATE TYPE "question_type" AS ENUM ('TEXT', 'MCQ', 'MULTIPLE_CHOICE', 'CHECKBOXES', 'DROPDOWNS', 'STAR_RATINGS');

-- CreateTable
CREATE TABLE "forms" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"title" TEXT,
"description" TEXT NOT NULL,
"created_by" TEXT,
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,

CONSTRAINT "forms_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "questions" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"form_id" UUID,
"question_text" TEXT NOT NULL DEFAULT '',
"question_type" "question_type",

CONSTRAINT "questions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "submissions" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"form_id" UUID,

CONSTRAINT "submissions_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "responses" (
"id" BIGSERIAL NOT NULL,
"created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"submission_id" UUID,
"question_id" UUID,
"answer" TEXT DEFAULT '',

CONSTRAINT "responses_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "questions" ADD CONSTRAINT "questions_form_id_fkey" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "submissions" ADD CONSTRAINT "submissions_form_id_fkey" FOREIGN KEY ("form_id") REFERENCES "forms"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "responses" ADD CONSTRAINT "responses_submission_id_fkey" FOREIGN KEY ("submission_id") REFERENCES "submissions"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "responses" ADD CONSTRAINT "responses_question_id_fkey" FOREIGN KEY ("question_id") REFERENCES "questions"("id") ON DELETE SET NULL ON UPDATE CASCADE;
237 changes: 149 additions & 88 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@ generator client {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
url = env("DIRECT_URL")
}

model User {
id String @id @default(cuid())
auth0Id String @unique
email String @unique
username String @unique
role UserRole @default(ORGANIZER)
status UserStatus @default(ACTIVE)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
profile UserProfile?
id String @id @default(cuid())
email String @unique
username String @unique
role UserRole @default(ORGANIZER)
status UserStatus @default(ACTIVE)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
auth0Id String @unique
applications Application[]
createdEvents Event[]
teamMembers TeamMember[]
education UserEducation[]
experience UserExperience[]
profile UserProfile?
skills UserSkill[]
socialProfiles UserSocialProfile[]
applications Application[]
createdEvents Event[]
teamMembers TeamMember[]
}

model UserProfile {
id Int @id @default(autoincrement())
userId String @unique
id Int @id @default(autoincrement())
userId String @unique
firstName String?
lastName String?
avatarUrl String?
Expand All @@ -37,20 +37,20 @@ model UserProfile {
phone String?
country String?
city String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model UserEducation {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
userId String
institutionName String
degree String
fieldOfStudy String
graduationYear Int?
createdAt DateTime @default(now())
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
createdAt DateTime @default(now())
degree String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model UserExperience {
Expand Down Expand Up @@ -83,31 +83,31 @@ model UserSocialProfile {
}

model Event {
id Int @id @default(autoincrement())
name String
type EventType
tagline String?
about String?
maxParticipants Int?
minTeamSize Int?
maxTeamSize Int?
mode EventMode @default(ONLINE)
status EventStatus @default(DRAFT)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdById String
createdBy User @relation(fields: [createdById], references: [id])
timeline EventTimeline?
links EventLink?
branding EventBranding?
tracks Track[]
sponsors Sponsor[]
eventPeople EventPerson[]
applications Application[]
applicationForm ApplicationForm?
customQuestions CustomQuestion[]
teams Team[]
projects ProjectSubmission[]
id Int @id @default(autoincrement())
name String
type EventType
tagline String?
about String?
maxParticipants Int?
minTeamSize Int?
maxTeamSize Int?
createdAt DateTime @default(now())
createdById String
mode EventMode @default(ONLINE)
status EventStatus @default(DRAFT)
updatedAt DateTime @updatedAt
applications Application[]
applicationForm ApplicationForm?
customQuestions CustomQuestion[]
createdBy User @relation(fields: [createdById], references: [id])
branding EventBranding?
links EventLink?
eventPeople EventPerson[]
timeline EventTimeline?
projects ProjectSubmission[]
sponsors Sponsor[]
teams Team[]
tracks Track[]
}

model ApplicationForm {
Expand All @@ -132,14 +132,14 @@ model CustomQuestion {
}

model EventTimeline {
id Int @id @default(autoincrement())
eventId Int @unique
eventStart DateTime
eventEnd DateTime
applicationsStart DateTime?
applicationsEnd DateTime?
rsvpDaysBeforeDeadline Int?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
eventId Int @unique
applicationsStart DateTime?
applicationsEnd DateTime?
eventStart DateTime
eventEnd DateTime
rsvpDaysBeforeDeadline Int?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
}

model EventLink {
Expand All @@ -148,17 +148,17 @@ model EventLink {
websiteUrl String?
micrositeUrl String?
contactEmail String?
socialLinks Json? // For storing multiple social media links
socialLinks Json?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
}

model EventBranding {
id Int @id @default(autoincrement())
eventId Int @unique
logoUrl String?
coverUrl String?
id Int @id @default(autoincrement())
eventId Int @unique
brandColor String?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
coverUrl String?
logoUrl String?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
}

model Track {
Expand All @@ -180,36 +180,36 @@ model Prize {
}

model Sponsor {
id Int @id @default(autoincrement())
eventId Int
name String
logoUrl String?
websiteUrl String?
tier SponsorTier
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
id Int @id @default(autoincrement())
eventId Int
name String
logoUrl String?
tier SponsorTier
websiteUrl String?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
}

model EventPerson {
id Int @id @default(autoincrement())
eventId Int
name String
role EventPersonRole
imageUrl String?
description String?
socialLinks Json?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
imageUrl String?
description String?
socialLinks Json?
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
}

model Team {
id Int @id @default(autoincrement())
id Int @id @default(autoincrement())
eventId Int
name String
hashCode String @unique
createdAt DateTime @default(now())
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
members TeamMember[]
createdAt DateTime @default(now())
hashCode String @unique
applications Application[]
projects ProjectSubmission[]
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
members TeamMember[]
}

model TeamMember {
Expand All @@ -222,17 +222,17 @@ model TeamMember {
}

model Application {
id Int @id @default(autoincrement())
eventId Int
userId String
teamId Int?
status ApplicationStatus
createdAt DateTime @default(now())
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id])
team Team? @relation(fields: [teamId], references: [id])
userData Json
responses Json
id Int @id @default(autoincrement())
eventId Int
userId String
teamId Int?
status ApplicationStatus
createdAt DateTime @default(now())
responses Json
userData Json
event Event @relation(fields: [eventId], references: [id], onDelete: Cascade)
team Team? @relation(fields: [teamId], references: [id])
user User @relation(fields: [userId], references: [id])
}

model ProjectSubmission {
Expand All @@ -249,6 +249,55 @@ model ProjectSubmission {
team Team @relation(fields: [teamId], references: [id])
}

model Form {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
title String?
description String
createdBy String? @map("created_by")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
questions Question[]
submissions Submission[]

@@map("forms")
}

model Question {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
formId String? @map("form_id") @db.Uuid
questionText String @default("") @map("question_text")
questionType QuestionType? @map("question_type")
options String[]
is_required Boolean? @default(false)
sort_order Int? @default(0)
form Form? @relation(fields: [formId], references: [id])
responses Response[]

@@map("questions")
}

model Submission {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
formId String? @map("form_id") @db.Uuid
responses Response[]
form Form? @relation(fields: [formId], references: [id])

@@map("submissions")
}

model Response {
id BigInt @id @default(autoincrement())
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6)
submissionId String? @map("submission_id") @db.Uuid
questionId String? @map("question_id") @db.Uuid
answer String? @default("")
question Question? @relation(fields: [questionId], references: [id])
submission Submission? @relation(fields: [submissionId], references: [id])

@@map("responses")
}

enum UserRole {
ADMIN
ORGANIZER
Expand Down Expand Up @@ -320,3 +369,15 @@ enum TeamMemberRole {
LEADER
MEMBER
}

enum QuestionType {
TEXT
MCQ
MULTIPLE_CHOICE
CHECKBOX
DROPDOWN
RATING
LONG_TEXT

@@map("question_type")
}
Loading