🗃️ Added modules to Prisma Scheme

This commit is contained in:
Axel Olausson Holtenäs 2022-10-19 10:21:15 +02:00
parent 551d0fbdcf
commit 999612086b
3 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,45 @@
-- AlterTable
ALTER TABLE "GuildMember" ADD COLUMN "creditsEarned" INTEGER;
ALTER TABLE "GuildMember" ADD COLUMN "pointsEarned" INTEGER;
-- CreateTable
CREATE TABLE "GuildCounter" (
"guildId" TEXT NOT NULL,
"channelId" TEXT NOT NULL,
"word" TEXT NOT NULL,
"counter" INTEGER NOT NULL DEFAULT 0,
CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Guild" (
"id" TEXT NOT NULL,
"creditsEnabled" BOOLEAN NOT NULL DEFAULT false,
"creditsRate" INTEGER NOT NULL DEFAULT 1,
"creditsTimeout" INTEGER NOT NULL DEFAULT 5,
"creditsWorkRate" INTEGER NOT NULL DEFAULT 25,
"creditsWorkTimeout" INTEGER NOT NULL DEFAULT 86400,
"pointsEnabled" BOOLEAN NOT NULL DEFAULT false,
"pointsRate" INTEGER NOT NULL DEFAULT 1,
"pointsTimeout" INTEGER NOT NULL DEFAULT 5,
"reputationsEnabled" BOOLEAN NOT NULL DEFAULT false,
"countersEnabled" BOOLEAN NOT NULL DEFAULT false
);
INSERT INTO "new_Guild" ("id") SELECT "id" FROM "Guild";
DROP TABLE "Guild";
ALTER TABLE "new_Guild" RENAME TO "Guild";
CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id");
CREATE TABLE "new_User" (
"id" TEXT NOT NULL,
"reputationsEarned" INTEGER NOT NULL DEFAULT 0
);
INSERT INTO "new_User" ("id") SELECT "id" FROM "User";
DROP TABLE "User";
ALTER TABLE "new_User" RENAME TO "User";
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;
-- CreateIndex
CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId");

View file

@ -0,0 +1,23 @@
/*
Warnings:
- You are about to drop the column `counter` on the `GuildCounter` table. All the data in the column will be lost.
- You are about to drop the column `word` on the `GuildCounter` table. All the data in the column will be lost.
- Added the required column `triggerWord` to the `GuildCounter` table without a default value. This is not possible if the table is not empty.
*/
-- RedefineTables
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_GuildCounter" (
"guildId" TEXT NOT NULL,
"channelId" TEXT NOT NULL,
"triggerWord" TEXT NOT NULL,
"count" INTEGER NOT NULL DEFAULT 0,
CONSTRAINT "GuildCounter_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_GuildCounter" ("channelId", "guildId") SELECT "channelId", "guildId" FROM "GuildCounter";
DROP TABLE "GuildCounter";
ALTER TABLE "new_GuildCounter" RENAME TO "GuildCounter";
CREATE UNIQUE INDEX "GuildCounter_guildId_channelId_key" ON "GuildCounter"("guildId", "channelId");
PRAGMA foreign_key_check;
PRAGMA foreign_keys=ON;

View file

@ -13,11 +13,34 @@ datasource db {
model Guild {
id String @unique
GuildMember GuildMember[]
// Settings
// Modules
creditsEnabled Boolean @default(false)
creditsRate Int @default(1)
creditsTimeout Int @default(5)
creditsWorkRate Int @default(25)
creditsWorkTimeout Int @default(86400)
pointsEnabled Boolean @default(false)
pointsRate Int @default(1)
pointsTimeout Int @default(5)
reputationsEnabled Boolean @default(false)
countersEnabled Boolean @default(false)
counters GuildCounter[]
}
model User {
id String @unique
GuildMember GuildMember[]
// Settings
// Modules
reputationsEarned Int @default(0)
}
model GuildMember {
@ -27,5 +50,22 @@ model GuildMember {
user User @relation(fields: [userId], references: [id])
guild Guild @relation(fields: [guildId], references: [id])
// Settings
// Modules
creditsEarned Int?
pointsEarned Int?
// Unique Identifier
@@unique([userId, guildId])
}
model GuildCounter {
guildId String
channelId String
triggerWord String
count Int @default(0)
guild Guild @relation(fields: [guildId], references: [id])
@@unique([guildId, channelId])
}