Version Estable
This commit is contained in:
BIN
prisma/dev.db
Normal file
BIN
prisma/dev.db
Normal file
Binary file not shown.
62
prisma/migrations/20250917001309_modals/migration.sql
Normal file
62
prisma/migrations/20250917001309_modals/migration.sql
Normal file
@@ -0,0 +1,62 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Guild" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PartnershipStats" (
|
||||
"totalPoints" INTEGER NOT NULL DEFAULT 0,
|
||||
"weeklyPoints" INTEGER NOT NULL DEFAULT 0,
|
||||
"monthlyPoints" INTEGER NOT NULL DEFAULT 0,
|
||||
"lastWeeklyReset" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"lastMonthlyReset" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"userId" TEXT NOT NULL,
|
||||
"guildId" TEXT NOT NULL,
|
||||
|
||||
PRIMARY KEY ("userId", "guildId"),
|
||||
CONSTRAINT "PartnershipStats_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "PartnershipStats_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Alliance" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"channelId" TEXT NOT NULL,
|
||||
"messageId" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"guildId" TEXT NOT NULL,
|
||||
"creatorId" TEXT NOT NULL,
|
||||
CONSTRAINT "Alliance_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "Alliance_creatorId_fkey" FOREIGN KEY ("creatorId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "EmbedConfig" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"color" TEXT,
|
||||
"title" TEXT,
|
||||
"url" TEXT,
|
||||
"authorName" TEXT,
|
||||
"authorIconURL" TEXT,
|
||||
"authorURL" TEXT,
|
||||
"description" TEXT,
|
||||
"thumbnailURL" TEXT,
|
||||
"imageURL" TEXT,
|
||||
"footerText" TEXT,
|
||||
"footerIconURL" TEXT,
|
||||
"fields" TEXT DEFAULT '[]',
|
||||
"guildId" TEXT NOT NULL,
|
||||
CONSTRAINT "EmbedConfig_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Alliance_messageId_key" ON "Alliance"("messageId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EmbedConfig_guildId_key" ON "EmbedConfig"("guildId");
|
||||
33
prisma/migrations/20250917002041_modals/migration.sql
Normal file
33
prisma/migrations/20250917002041_modals/migration.sql
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- Added the required column `name` to the `EmbedConfig` table without a default value. This is not possible if the table is not empty.
|
||||
|
||||
*/
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_EmbedConfig" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"color" TEXT,
|
||||
"title" TEXT,
|
||||
"url" TEXT,
|
||||
"authorName" TEXT,
|
||||
"authorIconURL" TEXT,
|
||||
"authorURL" TEXT,
|
||||
"description" TEXT,
|
||||
"thumbnailURL" TEXT,
|
||||
"imageURL" TEXT,
|
||||
"footerText" TEXT,
|
||||
"footerIconURL" TEXT,
|
||||
"fields" TEXT DEFAULT '[]',
|
||||
"guildId" TEXT NOT NULL,
|
||||
CONSTRAINT "EmbedConfig_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_EmbedConfig" ("authorIconURL", "authorName", "authorURL", "color", "description", "fields", "footerIconURL", "footerText", "guildId", "id", "imageURL", "thumbnailURL", "title", "url") SELECT "authorIconURL", "authorName", "authorURL", "color", "description", "fields", "footerIconURL", "footerText", "guildId", "id", "imageURL", "thumbnailURL", "title", "url" FROM "EmbedConfig";
|
||||
DROP TABLE "EmbedConfig";
|
||||
ALTER TABLE "new_EmbedConfig" RENAME TO "EmbedConfig";
|
||||
CREATE UNIQUE INDEX "EmbedConfig_guildId_name_key" ON "EmbedConfig"("guildId", "name");
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
13
prisma/migrations/20250917044008_modals/migration.sql
Normal file
13
prisma/migrations/20250917044008_modals/migration.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_Guild" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"prefix" TEXT NOT NULL DEFAULT '!'
|
||||
);
|
||||
INSERT INTO "new_Guild" ("id", "name") SELECT "id", "name" FROM "Guild";
|
||||
DROP TABLE "Guild";
|
||||
ALTER TABLE "new_Guild" RENAME TO "Guild";
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
3
prisma/migrations/migration_lock.toml
Normal file
3
prisma/migrations/migration_lock.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# Please do not edit this file manually
|
||||
# It should be added in your version-control system (e.g., Git)
|
||||
provider = "sqlite"
|
||||
133
prisma/schema.prisma
Normal file
133
prisma/schema.prisma
Normal file
@@ -0,0 +1,133 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
||||
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
* Modelo para el Servidor (Guild)
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
model Guild {
|
||||
id String @id
|
||||
name String
|
||||
prefix String @default("!")
|
||||
|
||||
// Relaciones
|
||||
alliances Alliance[]
|
||||
partnerStats PartnershipStats[]
|
||||
|
||||
// ✅ CAMBIO: Ahora un Guild puede tener MÚLTIPLES configuraciones de embed.
|
||||
embedConfigs EmbedConfig[]
|
||||
}
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
* Modelo para el Usuario
|
||||
* -----------------------------------------------------------------------------
|
||||
* Representa a un usuario de Discord de manera global.
|
||||
*/
|
||||
model User {
|
||||
id String @id
|
||||
|
||||
// Relaciones
|
||||
partnerStats PartnershipStats[]
|
||||
createdAlliances Alliance[]
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
* Modelo para las Estadísticas de Alianza (Leaderboard)
|
||||
* -----------------------------------------------------------------------------
|
||||
* Almacena los puntos de un usuario EN UN SERVIDOR específico.
|
||||
* Se gana 1 punto por mensaje en los canales registrados.
|
||||
*/
|
||||
model PartnershipStats {
|
||||
// Puntos acumulados totales.
|
||||
totalPoints Int @default(0)
|
||||
|
||||
// Puntos para la tabla de clasificación semanal.
|
||||
weeklyPoints Int @default(0)
|
||||
|
||||
// Puntos para la tabla de clasificación mensual.
|
||||
monthlyPoints Int @default(0)
|
||||
|
||||
// Fecha del último reinicio para controlar los contadores.
|
||||
lastWeeklyReset DateTime @default(now())
|
||||
lastMonthlyReset DateTime @default(now())
|
||||
|
||||
// --- Relaciones y Clave Primaria ---
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String
|
||||
guild Guild @relation(fields: [guildId], references: [id])
|
||||
guildId String
|
||||
|
||||
// Un usuario solo puede tener un registro de estadísticas por servidor.
|
||||
@@id([userId, guildId])
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
* Modelo para la Alianza (El mensaje publicado)
|
||||
* -----------------------------------------------------------------------------
|
||||
* Guarda la referencia al mensaje de alianza, pero no su contenido.
|
||||
* El contenido se construye dinámicamente usando EmbedConfig y PartnershipStats.
|
||||
*/
|
||||
model Alliance {
|
||||
id String @id @default(cuid())
|
||||
channelId String
|
||||
messageId String @unique
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
// --- Relaciones ---
|
||||
guild Guild @relation(fields: [guildId], references: [id])
|
||||
guildId String
|
||||
creator User @relation(fields: [creatorId], references: [id])
|
||||
creatorId String
|
||||
}
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------------------
|
||||
* Modelo para la Configuración del Embed
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
model EmbedConfig {
|
||||
id String @id @default(cuid())
|
||||
|
||||
// ✅ NUEVO: Un nombre único para identificar este embed dentro del servidor.
|
||||
// Ejemplos: "alianza", "bienvenida", "reglas"
|
||||
name String
|
||||
|
||||
// Campos del Embed (título, descripción, color, etc.)
|
||||
color String?
|
||||
title String?
|
||||
url String?
|
||||
authorName String?
|
||||
authorIconURL String?
|
||||
authorURL String?
|
||||
description String?
|
||||
thumbnailURL String?
|
||||
imageURL String?
|
||||
footerText String?
|
||||
footerIconURL String?
|
||||
fields String? @default("[]")
|
||||
|
||||
// --- Relación ---
|
||||
guild Guild @relation(fields: [guildId], references: [id])
|
||||
|
||||
// ✅ CAMBIO: Quitamos '@unique' para permitir que un guildId aparezca múltiples veces.
|
||||
guildId String
|
||||
|
||||
// ✅ NUEVO: Asegura que el 'name' sea único por cada servidor.
|
||||
// No puedes tener dos embeds llamados "alianza" en el mismo servidor.
|
||||
@@unique([guildId, name])
|
||||
}
|
||||
Reference in New Issue
Block a user