refactor(db): fix warning table to follow prisma naming convention

This commit is contained in:
smyalygames 2023-02-15 13:01:09 +00:00
parent d0d9dbacfd
commit eb345d1866
4 changed files with 26 additions and 4 deletions

View File

@ -0,0 +1,20 @@
/*
Warnings:
- You are about to drop the `Warnings` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "Warnings" DROP CONSTRAINT "Warnings_modId_fkey";
-- DropForeignKey
ALTER TABLE "Warnings" DROP CONSTRAINT "Warnings_userId_fkey";
-- RenameTable
ALTER TABLE "Warnings" RENAME TO "Warning";
-- AddForeignKey
ALTER TABLE "Warning" ADD CONSTRAINT "Warning_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Warning" ADD CONSTRAINT "Warning_modId_fkey" FOREIGN KEY ("modId") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Warning" RENAME CONSTRAINT "Warnings_pkey" TO "Warning_pkey";

View File

@ -39,8 +39,8 @@ model User {
VerifyVerifier Verify[] @relation("verVerifier")
SusUser Sus[] @relation("susUser")
SusMod Sus[] @relation("susMod")
WarnUser Warnings[] @relation("warnUser")
WarnMod Warnings[] @relation("warnMod")
WarnUser Warning[] @relation("warnUser")
WarnMod Warning[] @relation("warnMod")
RestrictUser Restrict[] @relation("restUser")
RestrictMod Restrict[] @relation("restMod")
RestrictEndMod Restrict[] @relation("endRestMod")
@ -93,7 +93,7 @@ model Sus {
note String
}
model Warnings {
model Warning {
id Int @id @default(autoincrement())
user User @relation("warnUser", fields: [userId], references: [id])
userId String

View File

@ -2,7 +2,7 @@ import { container } from '@sapphire/framework';
import type { Snowflake } from 'discord.js';
export async function addWarn(userId: Snowflake, modId: Snowflake, message: string) {
await container.database.warnings.create({
await container.database.warning.create({
data: {
user: {
connect: {