commit
75e03b42f7
99 files changed
+12285
No files matched your search
@@ -0,0 +1,136 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "User" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"username" TEXT NOT NULL,
|
||||
"passwordHash" TEXT NOT NULL,
|
||||
"role" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "World" (
|
||||
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 1,
|
||||
"name" TEXT NOT NULL DEFAULT 'My World',
|
||||
"tagline" TEXT NOT NULL DEFAULT '',
|
||||
"era" TEXT NOT NULL DEFAULT '',
|
||||
"theme" TEXT NOT NULL DEFAULT 'midnight',
|
||||
"accent" TEXT NOT NULL DEFAULT '#d9b46a',
|
||||
"showFog" BOOLEAN NOT NULL DEFAULT true,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Entry" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"slug" TEXT NOT NULL,
|
||||
"kind" TEXT NOT NULL,
|
||||
"title" TEXT NOT NULL,
|
||||
"subtitle" TEXT NOT NULL DEFAULT '',
|
||||
"summary" TEXT NOT NULL DEFAULT '',
|
||||
"body" TEXT NOT NULL DEFAULT '',
|
||||
"fields" TEXT NOT NULL DEFAULT '{}',
|
||||
"tags" TEXT NOT NULL DEFAULT '[]',
|
||||
"isPublic" BOOLEAN NOT NULL DEFAULT false,
|
||||
"stats" TEXT NOT NULL DEFAULT '{}',
|
||||
"abilities" TEXT NOT NULL DEFAULT '[]',
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" DATETIME NOT NULL
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Link" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"fromId" TEXT NOT NULL,
|
||||
"toId" TEXT NOT NULL,
|
||||
CONSTRAINT "Link_fromId_fkey" FOREIGN KEY ("fromId") REFERENCES "Entry" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "Link_toId_fkey" FOREIGN KEY ("toId") REFERENCES "Entry" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "TimelineEvent" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"year" INTEGER NOT NULL,
|
||||
"era" TEXT NOT NULL DEFAULT '',
|
||||
"label" TEXT NOT NULL,
|
||||
"text" TEXT NOT NULL DEFAULT '',
|
||||
"kind" TEXT NOT NULL DEFAULT 'lore',
|
||||
"entryId" TEXT,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "TimelineEvent_entryId_fkey" FOREIGN KEY ("entryId") REFERENCES "Entry" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "MapPin" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"x" REAL NOT NULL,
|
||||
"y" REAL NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"kind" TEXT NOT NULL DEFAULT 'location',
|
||||
"entryId" TEXT,
|
||||
CONSTRAINT "MapPin_entryId_fkey" FOREIGN KEY ("entryId") REFERENCES "Entry" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Quest" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"title" TEXT NOT NULL,
|
||||
"meta" TEXT NOT NULL DEFAULT '',
|
||||
"priority" TEXT NOT NULL DEFAULT 'normal',
|
||||
"status" TEXT NOT NULL DEFAULT 'active',
|
||||
"isPublic" BOOLEAN NOT NULL DEFAULT true,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PartyMember" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"klass" TEXT NOT NULL DEFAULT '',
|
||||
"hpCur" INTEGER NOT NULL DEFAULT 0,
|
||||
"hpMax" INTEGER NOT NULL DEFAULT 0,
|
||||
"color" TEXT NOT NULL DEFAULT '#d9b46a',
|
||||
"order" INTEGER NOT NULL DEFAULT 0
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "JournalEntry" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"who" TEXT NOT NULL,
|
||||
"color" TEXT NOT NULL DEFAULT '#d9b46a',
|
||||
"text" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "SessionBeat" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"entryId" TEXT NOT NULL,
|
||||
"time" TEXT NOT NULL DEFAULT '',
|
||||
"title" TEXT NOT NULL,
|
||||
"text" TEXT NOT NULL DEFAULT '',
|
||||
"flag" TEXT NOT NULL DEFAULT '',
|
||||
"order" INTEGER NOT NULL DEFAULT 0,
|
||||
CONSTRAINT "SessionBeat_entryId_fkey" FOREIGN KEY ("entryId") REFERENCES "Entry" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Thread" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"text" TEXT NOT NULL,
|
||||
"who" TEXT NOT NULL DEFAULT '',
|
||||
"primary" BOOLEAN NOT NULL DEFAULT false,
|
||||
"resolved" BOOLEAN NOT NULL DEFAULT false,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Entry_slug_key" ON "Entry"("slug");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "Link_fromId_toId_key" ON "Link"("fromId", "toId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "MapPin_entryId_key" ON "MapPin"("entryId");
|
||||
@@ -0,0 +1,32 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "MapLayer" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"imageData" TEXT NOT NULL DEFAULT '',
|
||||
"width" INTEGER NOT NULL DEFAULT 1000,
|
||||
"height" INTEGER NOT NULL DEFAULT 700,
|
||||
"isDefault" BOOLEAN NOT NULL DEFAULT false,
|
||||
"order" INTEGER NOT NULL DEFAULT 0,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- RedefineTables
|
||||
PRAGMA defer_foreign_keys=ON;
|
||||
PRAGMA foreign_keys=OFF;
|
||||
CREATE TABLE "new_MapPin" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"x" REAL NOT NULL,
|
||||
"y" REAL NOT NULL,
|
||||
"label" TEXT NOT NULL,
|
||||
"kind" TEXT NOT NULL DEFAULT 'location',
|
||||
"entryId" TEXT,
|
||||
"layerId" TEXT,
|
||||
CONSTRAINT "MapPin_entryId_fkey" FOREIGN KEY ("entryId") REFERENCES "Entry" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT "MapPin_layerId_fkey" FOREIGN KEY ("layerId") REFERENCES "MapLayer" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||
);
|
||||
INSERT INTO "new_MapPin" ("entryId", "id", "kind", "label", "x", "y") SELECT "entryId", "id", "kind", "label", "x", "y" FROM "MapPin";
|
||||
DROP TABLE "MapPin";
|
||||
ALTER TABLE "new_MapPin" RENAME TO "MapPin";
|
||||
CREATE UNIQUE INDEX "MapPin_entryId_key" ON "MapPin"("entryId");
|
||||
PRAGMA foreign_keys=ON;
|
||||
PRAGMA defer_foreign_keys=OFF;
|
||||
@@ -0,0 +1,46 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "Campaign" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"name" TEXT NOT NULL,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "CampaignMember" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"userId" TEXT NOT NULL,
|
||||
"campaignId" TEXT NOT NULL,
|
||||
CONSTRAINT "CampaignMember_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "CampaignMember_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "Campaign" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "EntryReveal" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"entryId" TEXT NOT NULL,
|
||||
"campaignId" TEXT NOT NULL,
|
||||
CONSTRAINT "EntryReveal_entryId_fkey" FOREIGN KEY ("entryId") REFERENCES "Entry" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT "EntryReveal_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "Campaign" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "InviteCode" (
|
||||
"id" TEXT NOT NULL PRIMARY KEY,
|
||||
"code" TEXT NOT NULL,
|
||||
"campaignId" TEXT,
|
||||
"role" TEXT NOT NULL DEFAULT 'player',
|
||||
"usedById" TEXT,
|
||||
"expiresAt" DATETIME,
|
||||
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT "InviteCode_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "Campaign" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT "InviteCode_usedById_fkey" FOREIGN KEY ("usedById") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "CampaignMember_userId_campaignId_key" ON "CampaignMember"("userId", "campaignId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "EntryReveal_entryId_campaignId_key" ON "EntryReveal"("entryId", "campaignId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "InviteCode_code_key" ON "InviteCode"("code");
|
||||
@@ -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"
|
||||
@@ -0,0 +1,185 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
username String @unique
|
||||
passwordHash String
|
||||
role String // "dm" | "player"
|
||||
createdAt DateTime @default(now())
|
||||
campaigns CampaignMember[]
|
||||
usedInvites InviteCode[] @relation("UsedInvites")
|
||||
}
|
||||
|
||||
model World {
|
||||
id Int @id @default(1)
|
||||
name String @default("My World")
|
||||
tagline String @default("")
|
||||
era String @default("")
|
||||
theme String @default("midnight")
|
||||
accent String @default("#d9b46a")
|
||||
showFog Boolean @default(true)
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model Entry {
|
||||
id String @id @default(cuid())
|
||||
slug String @unique
|
||||
kind String // location | npc | pc | faction | item | lore | session | beast | deity | rule | quest | culture
|
||||
title String
|
||||
subtitle String @default("")
|
||||
summary String @default("")
|
||||
body String @default("") // markdown-like, supports [[wikilinks]] and ::secret blocks
|
||||
fields String @default("{}") // JSON object {key:value}
|
||||
tags String @default("[]") // JSON array
|
||||
isPublic Boolean @default(false)
|
||||
// Bestiary-specific (JSON-encoded)
|
||||
stats String @default("{}") // JSON object
|
||||
abilities String @default("[]") // JSON array of {name,text}
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
outgoing Link[] @relation("from")
|
||||
incoming Link[] @relation("to")
|
||||
pin MapPin?
|
||||
beats SessionBeat[]
|
||||
timelineEvents TimelineEvent[]
|
||||
reveals EntryReveal[]
|
||||
}
|
||||
|
||||
model Link {
|
||||
id String @id @default(cuid())
|
||||
fromId String
|
||||
toId String
|
||||
from Entry @relation("from", fields: [fromId], references: [id], onDelete: Cascade)
|
||||
to Entry @relation("to", fields: [toId], references: [id], onDelete: Cascade)
|
||||
@@unique([fromId, toId])
|
||||
}
|
||||
|
||||
model TimelineEvent {
|
||||
id String @id @default(cuid())
|
||||
year Int
|
||||
era String @default("") // "Pre-Concord" / "Concord" etc.
|
||||
label String
|
||||
text String @default("")
|
||||
kind String @default("lore")
|
||||
entryId String?
|
||||
entry Entry? @relation(fields: [entryId], references: [id], onDelete: SetNull)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model MapPin {
|
||||
id String @id @default(cuid())
|
||||
x Float
|
||||
y Float
|
||||
label String
|
||||
kind String @default("location")
|
||||
entryId String? @unique
|
||||
entry Entry? @relation(fields: [entryId], references: [id], onDelete: SetNull)
|
||||
layerId String?
|
||||
layer MapLayer? @relation(fields: [layerId], references: [id], onDelete: SetNull)
|
||||
}
|
||||
|
||||
model MapLayer {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
imageData String @default("") // data: URL of an uploaded background, or "" for the procedural canvas
|
||||
width Int @default(1000)
|
||||
height Int @default(700)
|
||||
isDefault Boolean @default(false)
|
||||
order Int @default(0)
|
||||
createdAt DateTime @default(now())
|
||||
pins MapPin[]
|
||||
}
|
||||
|
||||
model Quest {
|
||||
id String @id @default(cuid())
|
||||
title String
|
||||
meta String @default("")
|
||||
priority String @default("normal") // critical | normal
|
||||
status String @default("active") // active | completed
|
||||
isPublic Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model PartyMember {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
klass String @default("")
|
||||
hpCur Int @default(0)
|
||||
hpMax Int @default(0)
|
||||
color String @default("#d9b46a")
|
||||
order Int @default(0)
|
||||
}
|
||||
|
||||
model JournalEntry {
|
||||
id String @id @default(cuid())
|
||||
who String
|
||||
color String @default("#d9b46a")
|
||||
text String
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model SessionBeat {
|
||||
id String @id @default(cuid())
|
||||
entryId String
|
||||
entry Entry @relation(fields: [entryId], references: [id], onDelete: Cascade)
|
||||
time String @default("")
|
||||
title String
|
||||
text String @default("")
|
||||
flag String @default("") // "" | rp | key | fight
|
||||
order Int @default(0)
|
||||
}
|
||||
|
||||
model Thread {
|
||||
id String @id @default(cuid())
|
||||
text String
|
||||
who String @default("")
|
||||
primary Boolean @default(false)
|
||||
resolved Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model Campaign {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
members CampaignMember[]
|
||||
reveals EntryReveal[]
|
||||
invites InviteCode[]
|
||||
}
|
||||
|
||||
model CampaignMember {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
campaignId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
|
||||
@@unique([userId, campaignId])
|
||||
}
|
||||
|
||||
model EntryReveal {
|
||||
id String @id @default(cuid())
|
||||
entryId String
|
||||
campaignId String
|
||||
entry Entry @relation(fields: [entryId], references: [id], onDelete: Cascade)
|
||||
campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
|
||||
@@unique([entryId, campaignId])
|
||||
}
|
||||
|
||||
model InviteCode {
|
||||
id String @id @default(cuid())
|
||||
code String @unique @default(cuid())
|
||||
campaignId String?
|
||||
role String @default("player")
|
||||
usedById String?
|
||||
expiresAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
campaign Campaign? @relation(fields: [campaignId], references: [id], onDelete: SetNull)
|
||||
usedBy User? @relation("UsedInvites", fields: [usedById], references: [id], onDelete: SetNull)
|
||||
}
|
||||
Reference in new issue
Block a user