mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-16 16:34:24 +02:00
Update initial schema
This commit is contained in:
+25
-18
@@ -64,18 +64,6 @@ CREATE TABLE "Server" (
|
|||||||
CONSTRAINT "Server_pkey" PRIMARY KEY ("id")
|
CONSTRAINT "Server_pkey" PRIMARY KEY ("id")
|
||||||
);
|
);
|
||||||
|
|
||||||
-- CreateTable
|
|
||||||
CREATE TABLE "ServerCredential" (
|
|
||||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
|
||||||
"credential" TEXT NOT NULL,
|
|
||||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
|
||||||
"serverId" UUID NOT NULL,
|
|
||||||
"userId" UUID NOT NULL,
|
|
||||||
|
|
||||||
CONSTRAINT "ServerCredential_pkey" PRIMARY KEY ("id")
|
|
||||||
);
|
|
||||||
|
|
||||||
-- CreateTable
|
-- CreateTable
|
||||||
CREATE TABLE "Folder" (
|
CREATE TABLE "Folder" (
|
||||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||||
@@ -112,12 +100,25 @@ CREATE TABLE "ServerUrl" (
|
|||||||
CONSTRAINT "ServerUrl_pkey" PRIMARY KEY ("id")
|
CONSTRAINT "ServerUrl_pkey" PRIMARY KEY ("id")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "UserServerUrl" (
|
||||||
|
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||||
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
|
"userId" UUID NOT NULL,
|
||||||
|
"serverUrlId" UUID NOT NULL,
|
||||||
|
"serverId" UUID NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "UserServerUrl_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
-- CreateTable
|
-- CreateTable
|
||||||
CREATE TABLE "ServerFolder" (
|
CREATE TABLE "ServerFolder" (
|
||||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||||
"name" TEXT NOT NULL,
|
"name" TEXT NOT NULL,
|
||||||
"remoteId" TEXT NOT NULL,
|
"remoteId" TEXT NOT NULL,
|
||||||
"enabled" BOOLEAN NOT NULL DEFAULT true,
|
"enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"lastScannedAt" TIMESTAMP(3),
|
||||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||||
"deleted" BOOLEAN NOT NULL DEFAULT false,
|
"deleted" BOOLEAN NOT NULL DEFAULT false,
|
||||||
@@ -507,6 +508,9 @@ CREATE UNIQUE INDEX "ServerPermission_userId_serverId_key" ON "ServerPermission"
|
|||||||
-- CreateIndex
|
-- CreateIndex
|
||||||
CREATE UNIQUE INDEX "ServerUrl_serverId_url_key" ON "ServerUrl"("serverId", "url");
|
CREATE UNIQUE INDEX "ServerUrl_serverId_url_key" ON "ServerUrl"("serverId", "url");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "UserServerUrl_userId_serverId_key" ON "UserServerUrl"("userId", "serverId");
|
||||||
|
|
||||||
-- CreateIndex
|
-- CreateIndex
|
||||||
CREATE UNIQUE INDEX "ServerFolder_remoteId_key" ON "ServerFolder"("remoteId");
|
CREATE UNIQUE INDEX "ServerFolder_remoteId_key" ON "ServerFolder"("remoteId");
|
||||||
|
|
||||||
@@ -699,12 +703,6 @@ ALTER TABLE "RefreshToken" ADD CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY
|
|||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "History" ADD CONSTRAINT "History_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
ALTER TABLE "History" ADD CONSTRAINT "History_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "ServerCredential" ADD CONSTRAINT "ServerCredential_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES "Server"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
|
||||||
ALTER TABLE "ServerCredential" ADD CONSTRAINT "ServerCredential_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
||||||
|
|
||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "Folder" ADD CONSTRAINT "Folder_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Folder"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
ALTER TABLE "Folder" ADD CONSTRAINT "Folder_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Folder"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
|
|
||||||
@@ -720,6 +718,15 @@ ALTER TABLE "ServerPermission" ADD CONSTRAINT "ServerPermission_serverId_fkey" F
|
|||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "ServerUrl" ADD CONSTRAINT "ServerUrl_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES "Server"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
ALTER TABLE "ServerUrl" ADD CONSTRAINT "ServerUrl_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES "Server"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "UserServerUrl" ADD CONSTRAINT "UserServerUrl_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "UserServerUrl" ADD CONSTRAINT "UserServerUrl_serverUrlId_fkey" FOREIGN KEY ("serverUrlId") REFERENCES "ServerUrl"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "UserServerUrl" ADD CONSTRAINT "UserServerUrl_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES "Server"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
-- AddForeignKey
|
-- AddForeignKey
|
||||||
ALTER TABLE "ServerFolder" ADD CONSTRAINT "ServerFolder_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES "Server"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
ALTER TABLE "ServerFolder" ADD CONSTRAINT "ServerFolder_serverId_fkey" FOREIGN KEY ("serverId") REFERENCES "Server"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
@@ -75,11 +75,12 @@ model User {
|
|||||||
|
|
||||||
serverFolderPermissions ServerFolderPermission[]
|
serverFolderPermissions ServerFolderPermission[]
|
||||||
serverPermissions ServerPermission[]
|
serverPermissions ServerPermission[]
|
||||||
serverCredentials ServerCredential[]
|
// serverCredentials ServerCredential[]
|
||||||
albumArtistFavorites AlbumArtistFavorite[]
|
albumArtistFavorites AlbumArtistFavorite[]
|
||||||
ArtistFavorite ArtistFavorite[]
|
artistFavorites ArtistFavorite[]
|
||||||
AlbumFavorite AlbumFavorite[]
|
albumFavorites AlbumFavorite[]
|
||||||
SongFavorite SongFavorite[]
|
songFavorites SongFavorite[]
|
||||||
|
userServerUrls UserServerUrl[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model History {
|
model History {
|
||||||
@@ -110,22 +111,25 @@ model Server {
|
|||||||
serverUrls ServerUrl[]
|
serverUrls ServerUrl[]
|
||||||
folders Folder[]
|
folders Folder[]
|
||||||
serverPermissions ServerPermission[]
|
serverPermissions ServerPermission[]
|
||||||
serverCredentials ServerCredential[]
|
// serverCredentials ServerCredential[]
|
||||||
tasks Task[]
|
tasks Task[]
|
||||||
|
userServerUrls UserServerUrl[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model ServerCredential {
|
// model ServerCredential {
|
||||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
// id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
credential String
|
// username String
|
||||||
createdAt DateTime @default(now())
|
// enabled Boolean @default(false)
|
||||||
updatedAt DateTime @updatedAt
|
// credential String
|
||||||
|
// createdAt DateTime @default(now())
|
||||||
|
// updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
// server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||||
serverId String @db.Uuid
|
// serverId String @db.Uuid
|
||||||
|
|
||||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
// user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
userId String @db.Uuid
|
// userId String @db.Uuid
|
||||||
}
|
// }
|
||||||
|
|
||||||
model Folder {
|
model Folder {
|
||||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
@@ -168,20 +172,39 @@ model ServerUrl {
|
|||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
|
|
||||||
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||||
serverId String @db.Uuid
|
serverId String @db.Uuid
|
||||||
|
userServerUrls UserServerUrl[]
|
||||||
|
|
||||||
@@unique(fields: [serverId, url], name: "uniqueServerUrlId")
|
@@unique(fields: [serverId, url], name: "uniqueServerUrlId")
|
||||||
}
|
}
|
||||||
|
|
||||||
model ServerFolder {
|
model UserServerUrl {
|
||||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
name String
|
|
||||||
remoteId String @unique
|
|
||||||
enabled Boolean @default(true)
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
deleted Boolean @default(false)
|
|
||||||
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||||
|
userId String @db.Uuid
|
||||||
|
|
||||||
|
serverUrl ServerUrl @relation(fields: [serverUrlId], references: [id], onDelete: Cascade)
|
||||||
|
serverUrlId String @db.Uuid
|
||||||
|
|
||||||
|
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||||
|
serverId String @db.Uuid
|
||||||
|
|
||||||
|
@@unique(fields: [userId, serverId], name: "uniqueUserServerUrlId")
|
||||||
|
}
|
||||||
|
|
||||||
|
model ServerFolder {
|
||||||
|
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||||
|
name String
|
||||||
|
remoteId String @unique
|
||||||
|
enabled Boolean @default(true)
|
||||||
|
lastScannedAt DateTime?
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
deleted Boolean @default(false)
|
||||||
|
|
||||||
albumArtists AlbumArtist[]
|
albumArtists AlbumArtist[]
|
||||||
artists Artist[]
|
artists Artist[]
|
||||||
|
|||||||
Reference in New Issue
Block a user