From 999612086b29870d2aecf8fa26637b8aa67638f5 Mon Sep 17 00:00:00 2001 From: Vermium Sifell Date: Wed, 19 Oct 2022 10:21:15 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Added=20modules=20to=20?= =?UTF-8?q?Prisma=20Scheme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221019081114_modules/migration.sql | 45 +++++++++++++++++++ .../20221019081816_modules/migration.sql | 23 ++++++++++ prisma/schema.prisma | 40 +++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 prisma/migrations/20221019081114_modules/migration.sql create mode 100644 prisma/migrations/20221019081816_modules/migration.sql diff --git a/prisma/migrations/20221019081114_modules/migration.sql b/prisma/migrations/20221019081114_modules/migration.sql new file mode 100644 index 0000000..2ada6f6 --- /dev/null +++ b/prisma/migrations/20221019081114_modules/migration.sql @@ -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"); diff --git a/prisma/migrations/20221019081816_modules/migration.sql b/prisma/migrations/20221019081816_modules/migration.sql new file mode 100644 index 0000000..4e87e61 --- /dev/null +++ b/prisma/migrations/20221019081816_modules/migration.sql @@ -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; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 81c8a30..be9bccf 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -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]) +}