mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +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")
|
||||
);
|
||||
|
||||
-- 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
|
||||
CREATE TABLE "Folder" (
|
||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||
@@ -112,12 +100,25 @@ CREATE TABLE "ServerUrl" (
|
||||
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
|
||||
CREATE TABLE "ServerFolder" (
|
||||
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
|
||||
"name" TEXT NOT NULL,
|
||||
"remoteId" TEXT NOT NULL,
|
||||
"enabled" BOOLEAN NOT NULL DEFAULT true,
|
||||
"lastScannedAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL,
|
||||
"deleted" BOOLEAN NOT NULL DEFAULT false,
|
||||
@@ -507,6 +508,9 @@ CREATE UNIQUE INDEX "ServerPermission_userId_serverId_key" ON "ServerPermission"
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ServerUrl_serverId_url_key" ON "ServerUrl"("serverId", "url");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "UserServerUrl_userId_serverId_key" ON "UserServerUrl"("userId", "serverId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ServerFolder_remoteId_key" ON "ServerFolder"("remoteId");
|
||||
|
||||
@@ -699,12 +703,6 @@ ALTER TABLE "RefreshToken" ADD CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY
|
||||
-- AddForeignKey
|
||||
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
|
||||
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
|
||||
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
|
||||
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[]
|
||||
serverPermissions ServerPermission[]
|
||||
serverCredentials ServerCredential[]
|
||||
// serverCredentials ServerCredential[]
|
||||
albumArtistFavorites AlbumArtistFavorite[]
|
||||
ArtistFavorite ArtistFavorite[]
|
||||
AlbumFavorite AlbumFavorite[]
|
||||
SongFavorite SongFavorite[]
|
||||
artistFavorites ArtistFavorite[]
|
||||
albumFavorites AlbumFavorite[]
|
||||
songFavorites SongFavorite[]
|
||||
userServerUrls UserServerUrl[]
|
||||
}
|
||||
|
||||
model History {
|
||||
@@ -110,22 +111,25 @@ model Server {
|
||||
serverUrls ServerUrl[]
|
||||
folders Folder[]
|
||||
serverPermissions ServerPermission[]
|
||||
serverCredentials ServerCredential[]
|
||||
// serverCredentials ServerCredential[]
|
||||
tasks Task[]
|
||||
userServerUrls UserServerUrl[]
|
||||
}
|
||||
|
||||
model ServerCredential {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
credential String
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
// model ServerCredential {
|
||||
// id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
// username String
|
||||
// enabled Boolean @default(false)
|
||||
// credential String
|
||||
// createdAt DateTime @default(now())
|
||||
// updatedAt DateTime @updatedAt
|
||||
|
||||
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||
serverId String @db.Uuid
|
||||
// server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||
// serverId String @db.Uuid
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String @db.Uuid
|
||||
}
|
||||
// user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
// userId String @db.Uuid
|
||||
// }
|
||||
|
||||
model Folder {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
@@ -168,20 +172,39 @@ model ServerUrl {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||
serverId String @db.Uuid
|
||||
server Server @relation(fields: [serverId], references: [id], onDelete: Cascade)
|
||||
serverId String @db.Uuid
|
||||
userServerUrls UserServerUrl[]
|
||||
|
||||
@@unique(fields: [serverId, url], name: "uniqueServerUrlId")
|
||||
}
|
||||
|
||||
model ServerFolder {
|
||||
model UserServerUrl {
|
||||
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
|
||||
name String
|
||||
remoteId String @unique
|
||||
enabled Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
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[]
|
||||
artists Artist[]
|
||||
|
||||
Reference in New Issue
Block a user