-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added friends and friendrequest relations for users
- Loading branch information
Rayahhhmed
committed
Oct 26, 2023
1 parent
81af2dc
commit d57e9e0
Showing
8 changed files
with
2,500 additions
and
5,454 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
server/prisma/migrations/20230906070029_init/migration.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"userId" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"lastLogin" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP, | ||
"firstname" TEXT, | ||
"lastname" TEXT, | ||
"email" TEXT NOT NULL, | ||
"profileURL" TEXT, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("userId") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Event" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"location" TEXT, | ||
"description" TEXT, | ||
"colour" TEXT NOT NULL DEFAULT '#1F7E8C', | ||
"day" TEXT NOT NULL, | ||
"start" TIMESTAMP(3) NOT NULL, | ||
"end" TIMESTAMP(3) NOT NULL, | ||
"timetableId" TEXT, | ||
|
||
CONSTRAINT "Event_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Class" ( | ||
"id" TEXT NOT NULL, | ||
"classType" TEXT NOT NULL, | ||
"courseName" TEXT, | ||
"timetableId" TEXT | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Timetable" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"selectedCourses" TEXT[], | ||
"userId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Timetable_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Settings" ( | ||
"userId" TEXT NOT NULL, | ||
"is12HourMode" BOOLEAN NOT NULL, | ||
"isDarkMode" BOOLEAN NOT NULL, | ||
"isSquareEdges" BOOLEAN NOT NULL, | ||
"isHideFullClasses" BOOLEAN NOT NULL, | ||
"isDefaultUnscheduled" BOOLEAN NOT NULL, | ||
"isHideClassInfo" BOOLEAN NOT NULL, | ||
"isSortAlphabetic" BOOLEAN NOT NULL, | ||
"isShowOnlyOpenClasses" BOOLEAN NOT NULL, | ||
"isHideExamClasses" BOOLEAN NOT NULL, | ||
"isConvertToLocalTimezone" BOOLEAN NOT NULL | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "_UserFriends" ( | ||
"A" TEXT NOT NULL, | ||
"B" TEXT NOT NULL | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Class_id_key" ON "Class"("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Timetable_id_key" ON "Timetable"("id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Settings_userId_key" ON "Settings"("userId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "_UserFriends_AB_unique" ON "_UserFriends"("A", "B"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "_UserFriends_B_index" ON "_UserFriends"("B"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Event" ADD CONSTRAINT "Event_timetableId_fkey" FOREIGN KEY ("timetableId") REFERENCES "Timetable"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Class" ADD CONSTRAINT "Class_timetableId_fkey" FOREIGN KEY ("timetableId") REFERENCES "Timetable"("id") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Timetable" ADD CONSTRAINT "Timetable_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Settings" ADD CONSTRAINT "Settings_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_UserFriends" ADD CONSTRAINT "_UserFriends_A_fkey" FOREIGN KEY ("A") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "_UserFriends" ADD CONSTRAINT "_UserFriends_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// prisma/seed.ts | ||
|
||
import { PrismaClient } from '@prisma/client'; | ||
// initialize Prisma Client | ||
const prisma = new PrismaClient(); | ||
const maximumZidNumber = 9e7; | ||
const minimumZidNumber = 1e7; | ||
|
||
const getZid = (): number => { | ||
return Math.floor(Math.random() * (maximumZidNumber - minimumZidNumber + 1) + minimumZidNumber); | ||
} | ||
// TODO | ||
const generateTimetable = async () => {} | ||
|
||
const generateUsers = async (numUsers: number, generateTimetablesForAllUsers? : boolean) => { | ||
for (let i = 0; i < numUsers; i++) { | ||
const zid = getZid().toString(); | ||
const user = await prisma.user.upsert({ | ||
where: { userId: zid}, | ||
update: {}, | ||
create: { | ||
userId: zid, | ||
email: `z${zid}@unsw.edu.au`, | ||
} | ||
}); | ||
console.log(user); | ||
} | ||
} | ||
|
||
async function main() { | ||
generateUsers(2); | ||
} | ||
|
||
// execute the main function | ||
main() | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}) | ||
.finally(async () => { | ||
await prisma.$disconnect(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { IsNotEmpty, IsString } from 'class-validator'; | ||
|
||
export class AuthDto { | ||
@IsString() | ||
@IsNotEmpty() | ||
code : string; | ||
@IsString() @IsNotEmpty() code : string; | ||
|
||
@IsString() | ||
@IsNotEmpty() | ||
state: string | ||
} | ||
@IsString() @IsNotEmpty() state: string; | ||
} |
Empty file.