mirror of
https://github.com/detleph/server.git
synced 2026-09-07 23:44:40 +02:00
boilerplate
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
import { PrismaClient } from '@prisma/client'
|
||||||
|
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
// ... you will write your Prisma Client queries here
|
||||||
|
console.log("Hello world!!")
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.catch((e) => {
|
||||||
|
throw e
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
await prisma.$disconnect()
|
||||||
|
})
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Event" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"date" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Event_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Admin" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"password" TEXT NOT NULL,
|
||||||
|
"level" INTEGER NOT NULL,
|
||||||
|
"eventId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Admin_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Campaign" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"ends" TIMESTAMP(3) NOT NULL,
|
||||||
|
"limit" INTEGER NOT NULL DEFAULT 40,
|
||||||
|
"curr" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"links" TEXT[],
|
||||||
|
"eventId" INTEGER NOT NULL,
|
||||||
|
"groupId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Campaign_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Discipline" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"minteamsize" INTEGER NOT NULL,
|
||||||
|
"maxteamsize" INTEGER NOT NULL,
|
||||||
|
"eventId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Discipline_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Teams" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"startdate" TIMESTAMP(3) NOT NULL,
|
||||||
|
"disciplineId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Teams_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Participant" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"firstname" TEXT NOT NULL,
|
||||||
|
"lastname" TEXT NOT NULL,
|
||||||
|
"email" TEXT NOT NULL,
|
||||||
|
"teamsId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Participant_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Oragnisation" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"eventId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Oragnisation_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Group" (
|
||||||
|
"id" INTEGER NOT NULL,
|
||||||
|
"name" TEXT NOT NULL,
|
||||||
|
"oragnisationId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Group_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Admin" ADD CONSTRAINT "Admin_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Campaign" ADD CONSTRAINT "Campaign_groupId_fkey" FOREIGN KEY ("groupId") REFERENCES "Group"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Campaign" ADD CONSTRAINT "Campaign_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Discipline" ADD CONSTRAINT "Discipline_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Teams" ADD CONSTRAINT "Teams_disciplineId_fkey" FOREIGN KEY ("disciplineId") REFERENCES "Discipline"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Participant" ADD CONSTRAINT "Participant_teamsId_fkey" FOREIGN KEY ("teamsId") REFERENCES "Teams"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Oragnisation" ADD CONSTRAINT "Oragnisation_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Group" ADD CONSTRAINT "Group_oragnisationId_fkey" FOREIGN KEY ("oragnisationId") REFERENCES "Oragnisation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@@ -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"
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
// This is your Prisma schema file,
|
||||||
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||||
|
|
||||||
|
datasource db {
|
||||||
|
provider = "postgresql"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
}
|
||||||
|
|
||||||
|
model Event {
|
||||||
|
id Int @id
|
||||||
|
date DateTime
|
||||||
|
disciplines Discipline[]
|
||||||
|
admins Admin[]
|
||||||
|
organisations Oragnisation[]
|
||||||
|
campaigns Campaign[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Admin {
|
||||||
|
id Int @id
|
||||||
|
name String
|
||||||
|
password String
|
||||||
|
level Int
|
||||||
|
event Event @relation(fields: [eventId], references: [id])
|
||||||
|
eventId Int
|
||||||
|
}
|
||||||
|
|
||||||
|
model Campaign {
|
||||||
|
id Int @id
|
||||||
|
ends DateTime
|
||||||
|
limit Int @default(40)
|
||||||
|
curr Int @default(0)
|
||||||
|
links String[]
|
||||||
|
group Group @relation(fields: [groupId], references: [id])
|
||||||
|
Event Event @relation(fields: [eventId], references: [id])
|
||||||
|
eventId Int
|
||||||
|
groupId Int
|
||||||
|
}
|
||||||
|
|
||||||
|
model Discipline {
|
||||||
|
id Int @id
|
||||||
|
name String
|
||||||
|
minteamsize Int
|
||||||
|
maxteamsize Int
|
||||||
|
event Event @relation(fields: [eventId], references: [id])
|
||||||
|
eventId Int
|
||||||
|
teams Teams[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Teams {
|
||||||
|
id Int @id
|
||||||
|
name String
|
||||||
|
startdate DateTime
|
||||||
|
participants Participant[]
|
||||||
|
discipline Discipline @relation(fields: [disciplineId], references: [id])
|
||||||
|
disciplineId Int
|
||||||
|
}
|
||||||
|
|
||||||
|
model Participant {
|
||||||
|
id Int @id
|
||||||
|
firstname String
|
||||||
|
lastname String
|
||||||
|
email String
|
||||||
|
teams Teams @relation(fields: [teamsId], references: [id])
|
||||||
|
teamsId Int
|
||||||
|
}
|
||||||
|
|
||||||
|
model Oragnisation {
|
||||||
|
id Int @id
|
||||||
|
name String
|
||||||
|
groups Group[]
|
||||||
|
Event Event @relation(fields: [eventId], references: [id])
|
||||||
|
eventId Int
|
||||||
|
}
|
||||||
|
|
||||||
|
model Group {
|
||||||
|
id Int @id
|
||||||
|
name String
|
||||||
|
Oragnisation Oragnisation @relation(fields: [oragnisationId], references: [id])
|
||||||
|
oragnisationId Int
|
||||||
|
Campaign Campaign[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"sourceMap": true,
|
||||||
|
"outDir": "dist",
|
||||||
|
"strict": true,
|
||||||
|
"lib": ["esnext"],
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user