Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
-- CreateTable
CREATE TABLE "MentorshipSessions" (
"id" SERIAL NOT NULL,
"mentor_id" INTEGER NOT NULL,
"description" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "MentorshipSessionsMentees" (
"id" SERIAL NOT NULL,
"mentee_id" INTEGER NOT NULL,
"session_id" INTEGER NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "MentorshipSessionsDates" (
"id" SERIAL NOT NULL,
"session_id" INTEGER NOT NULL,
"date" TIMESTAMP(3) NOT NULL,
"link" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "MentorshipSessionsDatesNotes" (
"id" SERIAL NOT NULL,
"session_date_id" INTEGER NOT NULL,
"user_id" INTEGER NOT NULL,
"notes" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "MentorshipSessionsRating" (
"id" SERIAL NOT NULL,
"session_id" INTEGER NOT NULL,
"rating_user_id" INTEGER NOT NULL,
"rating_user_role" "users_roles" NOT NULL,
"rated_user_id" INTEGER NOT NULL,
"rated_user_role" "users_roles" NOT NULL,
"comments" TEXT,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- AddForeignKey
ALTER TABLE "MentorshipSessions" ADD CONSTRAINT "MentorshipSessions_mentor_id_fkey" FOREIGN KEY ("mentor_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsMentees" ADD CONSTRAINT "MentorshipSessionsMentees_mentee_id_fkey" FOREIGN KEY ("mentee_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsMentees" ADD CONSTRAINT "MentorshipSessionsMentees_session_id_fkey" FOREIGN KEY ("session_id") REFERENCES "MentorshipSessions"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsDates" ADD CONSTRAINT "MentorshipSessionsDates_session_id_fkey" FOREIGN KEY ("session_id") REFERENCES "MentorshipSessions"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsDatesNotes" ADD CONSTRAINT "MentorshipSessionsDatesNotes_session_date_id_fkey" FOREIGN KEY ("session_date_id") REFERENCES "MentorshipSessionsDates"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsDatesNotes" ADD CONSTRAINT "MentorshipSessionsDatesNotes_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsRating" ADD CONSTRAINT "MentorshipSessionsRating_session_id_fkey" FOREIGN KEY ("session_id") REFERENCES "MentorshipSessions"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsRating" ADD CONSTRAINT "MentorshipSessionsRating_rating_user_id_fkey" FOREIGN KEY ("rating_user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsRating" ADD CONSTRAINT "MentorshipSessionsRating_rated_user_id_fkey" FOREIGN KEY ("rated_user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
Warnings:

- You are about to drop the column `created_at` on the `MentorshipSessions` table. All the data in the column will be lost.
- You are about to drop the column `description` on the `MentorshipSessions` table. All the data in the column will be lost.
- You are about to drop the column `mentor_id` on the `MentorshipSessions` table. All the data in the column will be lost.
- You are about to drop the `MentorshipSessionsDates` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `MentorshipSessionsDatesNotes` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `MentorshipSessionsMentees` table. If the table is not empty, all the data it contains will be lost.
- You are about to drop the `MentorshipSessionsRating` table. If the table is not empty, all the data it contains will be lost.
- Added the required column `dateEnd` to the `MentorshipSessions` table without a default value. This is not possible if the table is not empty.
- Added the required column `dateStart` to the `MentorshipSessions` table without a default value. This is not possible if the table is not empty.
- Added the required column `menteeId` to the `MentorshipSessions` table without a default value. This is not possible if the table is not empty.
- Added the required column `mentorId` to the `MentorshipSessions` table without a default value. This is not possible if the table is not empty.
- Added the required column `updatedAt` to the `MentorshipSessions` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "matching_status" AS ENUM ('PENDING', 'APPROVED', 'REJECTED', 'SUSPENDED');

-- DropForeignKey
ALTER TABLE "MentorshipSessions" DROP CONSTRAINT "MentorshipSessions_mentor_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsDates" DROP CONSTRAINT "MentorshipSessionsDates_session_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsDatesNotes" DROP CONSTRAINT "MentorshipSessionsDatesNotes_session_date_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsDatesNotes" DROP CONSTRAINT "MentorshipSessionsDatesNotes_user_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsMentees" DROP CONSTRAINT "MentorshipSessionsMentees_mentee_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsMentees" DROP CONSTRAINT "MentorshipSessionsMentees_session_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsRating" DROP CONSTRAINT "MentorshipSessionsRating_rated_user_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsRating" DROP CONSTRAINT "MentorshipSessionsRating_rating_user_id_fkey";

-- DropForeignKey
ALTER TABLE "MentorshipSessionsRating" DROP CONSTRAINT "MentorshipSessionsRating_session_id_fkey";

-- AlterTable
ALTER TABLE "MentorshipSessions" DROP COLUMN "created_at",
DROP COLUMN "description",
DROP COLUMN "mentor_id",
ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "dateEnd" TIMESTAMP(3) NOT NULL,
ADD COLUMN "dateStart" TIMESTAMP(3) NOT NULL,
ADD COLUMN "link" TEXT,
ADD COLUMN "menteeId" INTEGER NOT NULL,
ADD COLUMN "mentorId" INTEGER NOT NULL,
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL;

-- DropTable
DROP TABLE "MentorshipSessionsDates";

-- DropTable
DROP TABLE "MentorshipSessionsDatesNotes";

-- DropTable
DROP TABLE "MentorshipSessionsMentees";

-- DropTable
DROP TABLE "MentorshipSessionsRating";

-- CreateTable
CREATE TABLE "MentorshipSessionsDescriptions" (
"id" SERIAL NOT NULL,
"sessionId" INTEGER NOT NULL,
"description" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "MentorshipSessionsMenteeNotes" (
"id" SERIAL NOT NULL,
"sessionId" INTEGER NOT NULL,
"notes" TEXT NOT NULL,

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

-- CreateTable
CREATE TABLE "MentorshipSessionsMentorRating" (
"id" SERIAL NOT NULL,
"sessionId" INTEGER NOT NULL,
"rate" INTEGER NOT NULL,
"comment" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "MentorshipSessionsMenteeRating" (
"id" SERIAL NOT NULL,
"sessionId" INTEGER NOT NULL,
"rate" INTEGER NOT NULL,
"comment" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateTable
CREATE TABLE "MatchedMentorMentee" (
"id" SERIAL NOT NULL,
"mentorId" INTEGER NOT NULL,
"menteeId" INTEGER NOT NULL,
"status" "matching_status" NOT NULL DEFAULT 'PENDING',
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,

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

-- CreateIndex
CREATE UNIQUE INDEX "MentorshipSessionsMentorRating_sessionId_key" ON "MentorshipSessionsMentorRating"("sessionId");

-- CreateIndex
CREATE UNIQUE INDEX "MentorshipSessionsMenteeRating_sessionId_key" ON "MentorshipSessionsMenteeRating"("sessionId");

-- CreateIndex
CREATE UNIQUE INDEX "MatchedMentorMentee_mentorId_menteeId_key" ON "MatchedMentorMentee"("mentorId", "menteeId");

-- AddForeignKey
ALTER TABLE "MentorshipSessions" ADD CONSTRAINT "MentorshipSessions_mentorId_fkey" FOREIGN KEY ("mentorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessions" ADD CONSTRAINT "MentorshipSessions_menteeId_fkey" FOREIGN KEY ("menteeId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsDescriptions" ADD CONSTRAINT "MentorshipSessionsDescriptions_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "MentorshipSessions"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsMenteeNotes" ADD CONSTRAINT "MentorshipSessionsMenteeNotes_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "MentorshipSessions"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsMentorRating" ADD CONSTRAINT "MentorshipSessionsMentorRating_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "MentorshipSessions"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MentorshipSessionsMenteeRating" ADD CONSTRAINT "MentorshipSessionsMenteeRating_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "MentorshipSessions"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MatchedMentorMentee" ADD CONSTRAINT "MatchedMentorMentee_mentorId_fkey" FOREIGN KEY ("mentorId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "MatchedMentorMentee" ADD CONSTRAINT "MatchedMentorMentee_menteeId_fkey" FOREIGN KEY ("menteeId") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
81 changes: 80 additions & 1 deletion packages/backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,20 @@ model users {
created_at DateTime?
provider String?
deleted_at Boolean @default(false)
// MENTOR RELATIONSHIP

// MENTOR RELATIONSHIP
mentor mentors[]
// MENTEE RELATIONSHIP
mentee mentees[]

// MENTORSHIP SESSIONS - Updated relations
mentorSessions MentorshipSessions[] @relation("MentorSessions")
menteeSessions MentorshipSessions[] @relation("MenteeSessions")

// MATCHING RELATIONS
matchedAsMentor MatchedMentorMentee[] @relation("MatchedMentor")
matchedAsMentee MatchedMentorMentee[] @relation("MatchedMentee")

// EVENTS MANAGERS RELATIONSHIP
event_manager EventsManagers[]
// EVENTS SUBSCRIPTIONS RELATIONSHIP
Expand Down Expand Up @@ -548,4 +558,73 @@ model NewsletterSubscriptions {
}


// MENTORSHIP SESSIONS
model MentorshipSessions {
id Int @id @default(autoincrement())
mentorId Int
mentor users @relation("MentorSessions", fields: [mentorId], references: [id])
menteeId Int
mentee users @relation("MenteeSessions", fields: [menteeId], references: [id])
link String?
dateStart DateTime
dateEnd DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

// Relations
descriptions MentorshipSessionsDescriptions[]
menteeNotes MentorshipSessionsMenteeNotes[]
mentorRating MentorshipSessionsMentorRating?
menteeRating MentorshipSessionsMenteeRating?
}

model MentorshipSessionsDescriptions {
id Int @id @default(autoincrement())
sessionId Int
session MentorshipSessions @relation(fields: [sessionId], references: [id])
description String
}

model MentorshipSessionsMenteeNotes {
id Int @id @default(autoincrement())
sessionId Int
session MentorshipSessions @relation(fields: [sessionId], references: [id])
notes String
}

model MentorshipSessionsMentorRating {
id Int @id @default(autoincrement())
sessionId Int @unique
session MentorshipSessions @relation(fields: [sessionId], references: [id])
rate Int
comment String?
createdAt DateTime @default(now())
}

model MentorshipSessionsMenteeRating {
id Int @id @default(autoincrement())
sessionId Int @unique
session MentorshipSessions @relation(fields: [sessionId], references: [id])
rate Int
comment String?
createdAt DateTime @default(now())
}

enum matching_status {
PENDING
APPROVED
REJECTED
SUSPENDED
}

model MatchedMentorMentee {
id Int @id @default(autoincrement())
mentorId Int
mentor users @relation("MatchedMentor", fields: [mentorId], references: [id])
menteeId Int
mentee users @relation("MatchedMentee", fields: [menteeId], references: [id])
status matching_status @default(PENDING)
createdAt DateTime @default(now())

@@unique([mentorId, menteeId])
}
14 changes: 10 additions & 4 deletions packages/backend/src/admin/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,8 @@ export class AdminService {
const mentorApplications = await this.prisma.mentors.findMany({
orderBy: { created_at: 'desc' },
select: {
id: true,
id: true, // This is the mentor application ID
resume: true,
user: {
select: {
id: true,
Expand All @@ -818,7 +819,8 @@ export class AdminService {

const mappedMentorApplications: MentorshipAdmin[] =
mentorApplications.map((mentor) => ({
id: mentor.user.id,
id: mentor.user.id, // Keep user ID for backward compatibility
mentorApplicationId: mentor.id, // Add mentor application ID
identity: {
avatar: mentor.user.picture_upload_link,
firstName: mentor.user.first_name,
Expand All @@ -831,6 +833,7 @@ export class AdminService {
status: mentor.status,
capacity: mentor.max_mentees,
availability: mentor.availability,
resume: mentor.resume,
}));

return mappedMentorApplications;
Expand All @@ -845,7 +848,8 @@ export class AdminService {
const menteeApplications = await this.prisma.mentees.findMany({
orderBy: { created_at: 'desc' },
select: {
id: true,
id: true, // This is the mentee application ID
resume: true, // Add resume field
user: {
select: {
id: true,
Expand All @@ -865,7 +869,8 @@ export class AdminService {

const mappedMenteeApplications: MenteeAdmin[] = menteeApplications.map(
(mentee) => ({
id: mentee.user.id,
id: mentee.user.id, // Keep user ID for backward compatibility
menteeApplicationId: mentee.id, // Add mentee application ID
identity: {
avatar: mentee.user.picture_upload_link,
firstName: mentee.user.first_name,
Expand All @@ -877,6 +882,7 @@ export class AdminService {
email: mentee.user.email,
status: mentee.status,
experience: mentee.user.experience,
resume: mentee.resume, // Add resume field
}),
);

Expand Down
Loading