mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-11-03 15:49:50 +01:00
feat(db): finished database schema for outreach
This commit is contained in:
parent
07b5a6fcd8
commit
f8e99ef4f2
68
prisma/migrations/20230220171028_outreach/migration.sql
Normal file
68
prisma/migrations/20230220171028_outreach/migration.sql
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Event" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"leaderId" TEXT NOT NULL,
|
||||||
|
"startTime" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"endTime" TIMESTAMP(3),
|
||||||
|
"eventTypeType" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Event_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "EventType" (
|
||||||
|
"type" TEXT NOT NULL,
|
||||||
|
|
||||||
|
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
|
||||||
|
CREATE TABLE "Stat" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"leaderId" TEXT NOT NULL,
|
||||||
|
"vegan" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"considered" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"antivegan" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"thanked" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"documentary" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
"educated" INTEGER NOT NULL DEFAULT 0,
|
||||||
|
|
||||||
|
CONSTRAINT "Stat_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "ParticipantStat" (
|
||||||
|
"statId" INTEGER NOT NULL,
|
||||||
|
"userId" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "ParticipantStat_pkey" PRIMARY KEY ("statId","userId")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Event" ADD CONSTRAINT "Event_eventTypeType_fkey" FOREIGN KEY ("eventTypeType") REFERENCES "EventType"("type") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Event" ADD CONSTRAINT "Event_leaderId_fkey" FOREIGN KEY ("leaderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "EventStat" ADD CONSTRAINT "EventStat_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
|
||||||
|
ALTER TABLE "Stat" ADD CONSTRAINT "Stat_leaderId_fkey" FOREIGN KEY ("leaderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ParticipantStat" ADD CONSTRAINT "ParticipantStat_statId_fkey" FOREIGN KEY ("statId") REFERENCES "Stat"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "ParticipantStat" ADD CONSTRAINT "ParticipantStat_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@ -88,13 +88,19 @@ model Verify {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Event {
|
model Event {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
leader User @relation("eventLeader", fields: [leaderId], references: [id]) // Not sure if this will stay
|
type EventType @relation(fields: [eventTypeType], references: [type])
|
||||||
leaderId String
|
leader User @relation("eventLeader", fields: [leaderId], references: [id]) // Not sure if this will stay
|
||||||
startTime DateTime @default(now())
|
leaderId String
|
||||||
endTime DateTime?
|
startTime DateTime @default(now())
|
||||||
// Add a type of Event like Discord Outreach, Voice Chat, etc?
|
endTime DateTime?
|
||||||
EventStat EventStat[]
|
EventStat EventStat[]
|
||||||
|
eventTypeType String
|
||||||
|
}
|
||||||
|
|
||||||
|
model EventType {
|
||||||
|
type String @id
|
||||||
|
Event Event[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model EventStat {
|
model EventStat {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user