feat(db): add outreach to database

This commit is contained in:
smyalygames 2023-02-27 16:26:06 +00:00
parent 9fa412b15e
commit b859e4b617
2 changed files with 25 additions and 34 deletions

View File

@ -1,10 +1,10 @@
-- CreateTable -- CreateTable
CREATE TABLE "Event" ( CREATE TABLE "Event" (
"id" SERIAL NOT NULL, "id" SERIAL NOT NULL,
"eventType" TEXT NOT NULL,
"leaderId" TEXT NOT NULL, "leaderId" TEXT NOT NULL,
"startTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "startTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"endTime" TIMESTAMP(3), "endTime" TIMESTAMP(3),
"eventTypeType" TEXT NOT NULL,
CONSTRAINT "Event_pkey" PRIMARY KEY ("id") CONSTRAINT "Event_pkey" PRIMARY KEY ("id")
); );
@ -16,17 +16,10 @@ CREATE TABLE "EventType" (
CONSTRAINT "EventType_pkey" PRIMARY KEY ("type") CONSTRAINT "EventType_pkey" PRIMARY KEY ("type")
); );
-- CreateTable
CREATE TABLE "EventStat" (
"eventId" INTEGER NOT NULL,
"statId" INTEGER NOT NULL,
CONSTRAINT "EventStat_pkey" PRIMARY KEY ("eventId","statId")
);
-- CreateTable -- CreateTable
CREATE TABLE "Stat" ( CREATE TABLE "Stat" (
"id" SERIAL NOT NULL, "id" SERIAL NOT NULL,
"eventId" INTEGER NOT NULL,
"leaderId" TEXT NOT NULL, "leaderId" TEXT NOT NULL,
"vegan" INTEGER NOT NULL DEFAULT 0, "vegan" INTEGER NOT NULL DEFAULT 0,
"considered" INTEGER NOT NULL DEFAULT 0, "considered" INTEGER NOT NULL DEFAULT 0,
@ -47,16 +40,13 @@ CREATE TABLE "ParticipantStat" (
); );
-- AddForeignKey -- AddForeignKey
ALTER TABLE "Event" ADD CONSTRAINT "Event_eventTypeType_fkey" FOREIGN KEY ("eventTypeType") REFERENCES "EventType"("type") ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE "Event" ADD CONSTRAINT "Event_eventType_fkey" FOREIGN KEY ("eventType") REFERENCES "EventType"("type") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE "Event" ADD CONSTRAINT "Event_leaderId_fkey" FOREIGN KEY ("leaderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE "Event" ADD CONSTRAINT "Event_leaderId_fkey" FOREIGN KEY ("leaderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE "EventStat" ADD CONSTRAINT "EventStat_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE "Stat" ADD CONSTRAINT "Stat_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "EventStat" ADD CONSTRAINT "EventStat_statId_fkey" FOREIGN KEY ("statId") REFERENCES "Stat"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey -- AddForeignKey
ALTER TABLE "Stat" ADD CONSTRAINT "Stat_leaderId_fkey" FOREIGN KEY ("leaderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE; ALTER TABLE "Stat" ADD CONSTRAINT "Stat_leaderId_fkey" FOREIGN KEY ("leaderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -68,7 +68,7 @@ model Verify {
finishTime DateTime? finishTime DateTime?
manual Boolean @default(false) // If they were verified with the verify command manual Boolean @default(false) // If they were verified with the verify command
timedOut Boolean @default(false) // If they got kicked out of verification because they timed out timedOut Boolean @default(false) // If they got kicked out of verification because they timed out
//complete Boolean @default(false) // If the verification was incomplete // complete Boolean @default(false) // If the verification was incomplete
// Roles they got from verification // Roles they got from verification
vegan Boolean @default(false) // If they got verified as a vegan vegan Boolean @default(false) // If they got verified as a vegan
activist Boolean @default(false) // If they got the activist role when they verified activist Boolean @default(false) // If they got the activist role when they verified
@ -89,13 +89,13 @@ model Verify {
model Event { model Event {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
type EventType @relation(fields: [eventTypeType], references: [type]) type EventType @relation(fields: [eventType], references: [type])
eventType String
leader User @relation("eventLeader", fields: [leaderId], references: [id]) // Not sure if this will stay leader User @relation("eventLeader", fields: [leaderId], references: [id]) // Not sure if this will stay
leaderId String leaderId String
startTime DateTime @default(now()) startTime DateTime @default(now())
endTime DateTime? endTime DateTime?
EventStat EventStat[] stats Stat[]
eventTypeType String
} }
model EventType { model EventType {
@ -105,6 +105,8 @@ model EventType {
model Stat { model Stat {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
event Event @relation(fields: [eventId], references: [id])
eventId Int
leader User @relation("statLeader", fields: [leaderId], references: [id]) // Not sure if this will stay leader User @relation("statLeader", fields: [leaderId], references: [id]) // Not sure if this will stay
leaderId String leaderId String
vegan Int @default(0) vegan Int @default(0)
@ -113,8 +115,7 @@ model Stat {
thanked Int @default(0) thanked Int @default(0)
documentary Int @default(0) documentary Int @default(0)
educated Int @default(0) educated Int @default(0)
EventStat EventStat[] participationStats ParticipantStat[]
ParticipantStat ParticipantStat[]
} }
model ParticipantStat { model ParticipantStat {