-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2f587c
commit c008b0d
Showing
6 changed files
with
308 additions
and
16 deletions.
There are no files selected for viewing
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
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,96 @@ | ||
-- CreateEnum | ||
CREATE TYPE "Wing" AS ENUM ('FOSS', 'GAME_DEV', 'CP', 'NETWORKING', 'CYBERSECURITY'); | ||
|
||
-- CreateEnum | ||
CREATE TYPE "Role" AS ENUM ('DEVELOPER', 'ASSET_DES', 'MUSIC_COMP', 'STORY_WRITING', 'ENV_DES'); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Members" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
"roll_number" INTEGER NOT NULL, | ||
"wing" "Wing" NOT NULL, | ||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updated_at" TIMESTAMP(3) NOT NULL, | ||
|
||
CONSTRAINT "Members_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Codeforces" ( | ||
"id" SERIAL NOT NULL, | ||
"handle" TEXT NOT NULL, | ||
"rating" INTEGER NOT NULL, | ||
"num_participants" INTEGER NOT NULL, | ||
"member_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Codeforces_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Leetcode" ( | ||
"id" SERIAL NOT NULL, | ||
"handle" TEXT NOT NULL, | ||
"rank" INTEGER NOT NULL, | ||
"solved" INTEGER NOT NULL, | ||
"member_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Leetcode_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "GameDev" ( | ||
"id" SERIAL NOT NULL, | ||
"role" "Role" NOT NULL, | ||
"member_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "GameDev_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "FOSS" ( | ||
"id" SERIAL NOT NULL, | ||
"github_uname" TEXT NOT NULL, | ||
"member_id" TEXT NOT NULL, | ||
|
||
CONSTRAINT "FOSS_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Members_roll_number_key" ON "Members"("roll_number"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "Members_roll_number_idx" ON "Members"("roll_number"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Codeforces_handle_key" ON "Codeforces"("handle"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Codeforces_member_id_key" ON "Codeforces"("member_id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Leetcode_handle_key" ON "Leetcode"("handle"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Leetcode_member_id_key" ON "Leetcode"("member_id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "GameDev_member_id_key" ON "GameDev"("member_id"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "FOSS_github_uname_key" ON "FOSS"("github_uname"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "FOSS_member_id_key" ON "FOSS"("member_id"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Codeforces" ADD CONSTRAINT "Codeforces_member_id_fkey" FOREIGN KEY ("member_id") REFERENCES "Members"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Leetcode" ADD CONSTRAINT "Leetcode_member_id_fkey" FOREIGN KEY ("member_id") REFERENCES "Members"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "GameDev" ADD CONSTRAINT "GameDev_member_id_fkey" FOREIGN KEY ("member_id") REFERENCES "Members"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "FOSS" ADD CONSTRAINT "FOSS_member_id_fkey" FOREIGN KEY ("member_id") REFERENCES "Members"("id") ON DELETE RESTRICT 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
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,3 +1,71 @@ | ||
import { PrismaClient } from '@prisma/client' | ||
|
||
const prisma = new PrismaClient() | ||
|
||
async function main() { | ||
const shubh = await prisma.members.upsert({ | ||
where: { roll_number: 210020047 }, | ||
update: {}, | ||
create: { | ||
roll_number: 210020047, | ||
name: 'Shubh Agarwal', | ||
wing: 'FOSS', | ||
leetcode: { | ||
create: { | ||
handle: 'shubhagarwal539', | ||
solved: 83, | ||
rank: 754120, | ||
}, | ||
}, | ||
foss: { | ||
create: { | ||
github_uname: 'ShubhAgarwal-dev', | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const saksham = await prisma.members.upsert({ | ||
where: { roll_number: 210010046 }, | ||
update: {}, | ||
create: { | ||
name: 'Saksham Chhimwal', | ||
roll_number: 210010046, | ||
wing: 'FOSS', | ||
codeforces: { | ||
create: { | ||
handle: 'saksham', | ||
rating: 969, | ||
num_participants: 10, | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const ayush = await prisma.members.upsert({ | ||
where: { roll_number: 210020048 }, | ||
update: {}, | ||
create: { | ||
name: 'Ayush Singhi', | ||
roll_number: 210020048, | ||
wing: 'GAME_DEV', | ||
game_dev: { | ||
create: { | ||
role: 'ASSET_DES', | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
console.log(shubh, saksham, ayush) | ||
} | ||
|
||
main() | ||
.then(async () => { | ||
await prisma.$disconnect() | ||
}) | ||
.catch(async e => { | ||
console.error(e) | ||
await prisma.$disconnect() | ||
process.exit(1) | ||
}) |
Oops, something went wrong.