mirror of
https://github.com/veganhacktivists/arabot.git
synced 2025-05-18 18:14:15 +02:00
feat(database): add economy
This commit is contained in:
parent
b404a26bdc
commit
de94b88be1
41
prisma/migrations/20230302130212_economy/migration.sql
Normal file
41
prisma/migrations/20230302130212_economy/migration.sql
Normal file
@ -0,0 +1,41 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Balance" (
|
||||
"userId" TEXT NOT NULL,
|
||||
"balance" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "Balance_pkey" PRIMARY KEY ("userId")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Daily" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"amount" INTEGER NOT NULL,
|
||||
"time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "Daily_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Payment" (
|
||||
"id" SERIAL NOT NULL,
|
||||
"senderId" TEXT NOT NULL,
|
||||
"recipientId" TEXT NOT NULL,
|
||||
"amount" INTEGER NOT NULL,
|
||||
"reason" TEXT NOT NULL,
|
||||
"time" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "Payment_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Balance" ADD CONSTRAINT "Balance_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Daily" ADD CONSTRAINT "Daily_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Payment" ADD CONSTRAINT "Payment_senderId_fkey" FOREIGN KEY ("senderId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Payment" ADD CONSTRAINT "Payment_recipientId_fkey" FOREIGN KEY ("recipientId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
@ -37,6 +37,10 @@ model User {
|
||||
muted Boolean @default(false)
|
||||
VerifyUser Verify[] @relation("verUser")
|
||||
VerifyVerifier Verify[] @relation("verVerifier")
|
||||
Balance Balance?
|
||||
Daily Daily[]
|
||||
SendPayment Payment[] @relation("sendPayment")
|
||||
RecievePayment Payment[] @relation("recievePayment")
|
||||
LeaveLog LeaveLog[]
|
||||
EventLeader Event[] @relation("eventLeader")
|
||||
StatLeader Stat[] @relation("statLeader")
|
||||
@ -88,6 +92,35 @@ model Verify {
|
||||
notes String?
|
||||
}
|
||||
|
||||
// Economy
|
||||
|
||||
model Balance {
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String @id
|
||||
balance Int
|
||||
}
|
||||
|
||||
model Daily {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
amount Int
|
||||
time DateTime @default(now())
|
||||
}
|
||||
|
||||
model Payment {
|
||||
id Int @id @default(autoincrement())
|
||||
sender User @relation("sendPayment", fields: [senderId], references: [id])
|
||||
senderId String
|
||||
recipient User @relation("recievePayment", fields: [recipientId], references: [id])
|
||||
recipientId String
|
||||
amount Int
|
||||
reason String
|
||||
time DateTime @default(now())
|
||||
}
|
||||
|
||||
// Tracking roles for leaving the server
|
||||
|
||||
model LeaveLog {
|
||||
id Int @id @default(autoincrement())
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
|
Loading…
x
Reference in New Issue
Block a user