🗃️ Added prisma scheme
This commit is contained in:
parent
0ecb6f2c4a
commit
709c913426
4 changed files with 72 additions and 0 deletions
24
prisma/migrations/20221019063840_init/migration.sql
Normal file
24
prisma/migrations/20221019063840_init/migration.sql
Normal file
|
@ -0,0 +1,24 @@
|
|||
-- CreateTable
|
||||
CREATE TABLE "Guild" (
|
||||
"id" TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "GuildMember" (
|
||||
"userId" TEXT NOT NULL,
|
||||
"guildId" TEXT NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Guild_id_key" ON "Guild"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_id_key" ON "User"("id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId");
|
14
prisma/migrations/20221019064232_init/migration.sql
Normal file
14
prisma/migrations/20221019064232_init/migration.sql
Normal file
|
@ -0,0 +1,14 @@
|
|||
-- RedefineTables
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_GuildMember" (
|
||||
"userId" TEXT NOT NULL,
|
||||
"guildId" TEXT NOT NULL,
|
||||
CONSTRAINT "GuildMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||
CONSTRAINT "GuildMember_guildId_fkey" FOREIGN KEY ("guildId") REFERENCES "Guild" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_GuildMember" ("guildId", "userId") SELECT "guildId", "userId" FROM "GuildMember";
|
||||
DROP TABLE "GuildMember";
|
||||
ALTER TABLE "new_GuildMember" RENAME TO "GuildMember";
|
||||
CREATE UNIQUE INDEX "GuildMember_userId_guildId_key" ON "GuildMember"("userId", "guildId");
|
||||
PRAGMA foreign_key_check;
|
||||
PRAGMA foreign_keys=ON;
|
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 (i.e. Git)
|
||||
provider = "sqlite"
|
31
prisma/schema.prisma
Normal file
31
prisma/schema.prisma
Normal file
|
@ -0,0 +1,31 @@
|
|||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Guild {
|
||||
id String @unique
|
||||
GuildMember GuildMember[]
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @unique
|
||||
GuildMember GuildMember[]
|
||||
}
|
||||
|
||||
model GuildMember {
|
||||
userId String
|
||||
guildId String
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
guild Guild @relation(fields: [guildId], references: [id])
|
||||
|
||||
@@unique([userId, guildId])
|
||||
}
|
Loading…
Add table
Reference in a new issue