diff --git a/package.json b/package.json index f52a88b..7db56cf 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "@astrojs/react": "4.1.3", "@astrojs/rss": "4.0.11", "@inlang/paraglide-astro": "^0.2.2", - "@prisma/client": "^6.4.0", + "@prisma/client": "^6.4.1", "@tailwindcss/vite": "^4.0.7", "@types/react": "^18.3.12", "@types/react-dom": "^18.3.1", @@ -23,6 +23,7 @@ "better-auth": "^1.1.11", "clsx": "^2.1.1", "nodemailer": "^6.10.0", + "prisma": "^6.4.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-hot-toast": "^2.4.1", @@ -42,7 +43,6 @@ "eslint-plugin-jsx-a11y": "^6.10.0", "neostandard": "^0.11.6", "prettier": "^3.3.3", - "prettier-config-standard": "^7.0.0", - "prisma": "^6.4.0" + "prettier-config-standard": "^7.0.0" } } diff --git a/prisma/migrations/20250226030242_cleanup_relation_schema/migration.sql b/prisma/migrations/20250226030242_cleanup_relation_schema/migration.sql new file mode 100644 index 0000000..66fada9 --- /dev/null +++ b/prisma/migrations/20250226030242_cleanup_relation_schema/migration.sql @@ -0,0 +1,183 @@ +/* + - Made the column `albumId` on table `discs` required. This step will fail if there are existing NULL values in that column. + - Made the column `albumId` on table `downloads` required. This step will fail if there are existing NULL values in that column. + - Made the column `albumId` on table `favorites` required. This step will fail if there are existing NULL values in that column. + - Made the column `albumId` on table `linkCategories` required. This step will fail if there are existing NULL values in that column. + - Made the column `downloadId` on table `links` required. This step will fail if there are existing NULL values in that column. + - Made the column `score` on table `ratings` required. This step will fail if there are existing NULL values in that column. + - Made the column `albumId` on table `ratings` required. This step will fail if there are existing NULL values in that column. + - Made the column `username` on table `ratings` required. This step will fail if there are existing NULL values in that column. +*/ + +SET FOREIGN_KEY_CHECKS = 0; + +-- DropForeignKey +ALTER TABLE `animation` DROP FOREIGN KEY `animation_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `discs` DROP FOREIGN KEY `discs_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `downloads` DROP FOREIGN KEY `downloads_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `favorites` DROP FOREIGN KEY `favorites_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `linkCategories` DROP FOREIGN KEY `linkCategories_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `links` DROP FOREIGN KEY `links_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `logs` DROP FOREIGN KEY `logs_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `ratings` DROP FOREIGN KEY `ratings_ibfk_1`; + +-- DropForeignKey +ALTER TABLE `ratings` DROP FOREIGN KEY `ratings_ibfk_2`; + +-- DropIndex +DROP INDEX `studioSlug` ON `animation`; + +-- DropIndex +DROP INDEX `ostId` ON `discs`; + +-- DropIndex +DROP INDEX `ostId` ON `downloads`; + +-- DropIndex +DROP INDEX `ostId` ON `favorites`; + +-- DropIndex +DROP INDEX `ostId` ON `linkCategories`; + +-- DropIndex +DROP INDEX `downloadId` ON `links`; + +-- DropIndex +DROP INDEX `username` ON `logs`; + +-- DropIndex +DROP INDEX `ostId` ON `ratings`; + +-- DropIndex +DROP INDEX `username` ON `ratings`; + +-- AlterTable +ALTER TABLE `Album_Animation` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Album_Artist` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Album_Category` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Album_Classification` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Album_Game` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Album_Platform` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Album_Type` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Game_Platform` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Publisher_Game` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Series_Game` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `Studio_Animation` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `User_Role` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +DELETE FROM `discs` WHERE `albumId` IS NULL; +ALTER TABLE `discs` MODIFY `albumId` INTEGER NOT NULL; + +-- AlterTable +DELETE FROM `downloads` WHERE `albumId` IS NULL; +ALTER TABLE `downloads` MODIFY `albumId` INTEGER NOT NULL; + +-- AlterTable +DELETE FROM `favorites` WHERE `albumId` IS NULL; +ALTER TABLE `favorites` MODIFY `albumId` INTEGER NOT NULL; + +-- AlterTable +DELETE FROM `linkCategories` WHERE `albumId` IS NULL; +ALTER TABLE `linkCategories` MODIFY `albumId` INTEGER NOT NULL; + +-- AlterTable +DELETE FROM `links` WHERE `downloadId` IS NULL; +ALTER TABLE `links` MODIFY `downloadId` INTEGER NOT NULL; + +-- AlterTable +DELETE FROM `ratings` + WHERE `score` IS NULL + OR `albumId` IS NULL + OR `username` IS NULL; +ALTER TABLE `ratings` + MODIFY `score` INTEGER NOT NULL, + MODIFY `albumId` INTEGER NOT NULL, + MODIFY `username` VARCHAR(255) NOT NULL; + +-- AlterTable +ALTER TABLE `related_album` DROP COLUMN `createdAt`, + DROP COLUMN `updatedAt`; + +-- AlterTable +ALTER TABLE `type` + DROP COLUMN `updatedAt`, + DROP COLUMN `createdAt`, + MODIFY `name` VARCHAR(255) NOT NULL; + +-- DropTable +DROP TABLE `SequelizeMeta`; + +-- AddForeignKey +ALTER TABLE `discs` ADD CONSTRAINT `discs_ibfk_1` FOREIGN KEY (`albumId`) REFERENCES `albums`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `downloads` ADD CONSTRAINT `downloads_ibfk_1` FOREIGN KEY (`albumId`) REFERENCES `albums`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `favorites` ADD CONSTRAINT `favorites_ibfk_1` FOREIGN KEY (`albumId`) REFERENCES `albums`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `linkCategories` ADD CONSTRAINT `linkCategories_ibfk_1` FOREIGN KEY (`albumId`) REFERENCES `albums`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `links` ADD CONSTRAINT `links_ibfk_1` FOREIGN KEY (`downloadId`) REFERENCES `downloads`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `logs` ADD CONSTRAINT `logs_ibfk_1` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `ratings` ADD CONSTRAINT `ratings_ibfk_1` FOREIGN KEY (`albumId`) REFERENCES `albums`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `ratings` ADD CONSTRAINT `ratings_ibfk_2` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +SET FOREIGN_KEY_CHECKS = 1; \ No newline at end of file diff --git a/prisma/migrations/20250226040518_cleanup_relation_schema_2/migration.sql b/prisma/migrations/20250226040518_cleanup_relation_schema_2/migration.sql new file mode 100644 index 0000000..c9da595 --- /dev/null +++ b/prisma/migrations/20250226040518_cleanup_relation_schema_2/migration.sql @@ -0,0 +1,12 @@ +SET FOREIGN_KEY_CHECKS = 0; + +-- DropForeignKey +ALTER TABLE `logs` DROP FOREIGN KEY `logs_ibfk_1`; + +-- DropIndex +DROP INDEX `logs_ibfk_1` ON `logs`; + +-- AddForeignKey +ALTER TABLE `logs` ADD CONSTRAINT `logs_ibfk_1` FOREIGN KEY (`username`) REFERENCES `users`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +SET FOREIGN_KEY_CHECKS = 1; \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 33a2218..f0d6762 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -9,151 +9,111 @@ datasource db { } model Album_Animation { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) albumId Int animationId Int - albums albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Animation_ibfk_1") + album albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Animation_ibfk_1") animation animation @relation(fields: [animationId], references: [id], onDelete: Cascade, map: "Album_Animation_ibfk_2") @@id([albumId, animationId]) - @@index([animationId], map: "animationId") } model Album_Artist { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) albumId Int - artistSlug String @db.VarChar(255) - albums albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Artist_ibfk_1") - artist artist @relation(fields: [artistSlug], references: [slug], onDelete: Cascade, map: "Album_Artist_ibfk_2") + artistSlug String @db.VarChar(255) + album albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Artist_ibfk_1") + artist artist @relation(fields: [artistSlug], references: [slug], onDelete: Cascade, map: "Album_Artist_ibfk_2") @@id([albumId, artistSlug]) - @@index([artistSlug], map: "artistSlug") } model Album_Category { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) categoryName String @db.VarChar(255) albumId Int category category @relation(fields: [categoryName], references: [name], onDelete: Cascade, map: "Album_Category_ibfk_1") albums albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Category_ibfk_2") @@id([categoryName, albumId]) - @@index([albumId], map: "ostId") } model Album_Classification { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) albumId Int classificationName String @db.VarChar(255) - albums albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Classification_ibfk_1") + album albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Classification_ibfk_1") classification classification @relation(fields: [classificationName], references: [name], onDelete: Cascade, map: "Album_Classification_ibfk_2") @@id([albumId, classificationName]) - @@index([classificationName], map: "categoryName") } model Album_Game { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - gameSlug String @db.VarChar(255) - albumId Int - game game @relation(fields: [gameSlug], references: [slug], onDelete: Cascade, map: "Album_Game_ibfk_1") - albums albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Game_ibfk_2") + gameSlug String @db.VarChar(255) + albumId Int + game game @relation(fields: [gameSlug], references: [slug], onDelete: Cascade, map: "Album_Game_ibfk_1") + album albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Game_ibfk_2") @@id([gameSlug, albumId]) - @@index([albumId], map: "ostId") } model Album_Platform { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) albumId Int platformId Int - albums albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Platform_ibfk_1") + album albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Platform_ibfk_1") platform platform @relation(fields: [platformId], references: [id], onDelete: Cascade, map: "Album_Platform_ibfk_2") @@id([albumId, platformId]) - @@index([platformId], map: "platformId") } model Album_Type { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - albumId Int - typeId Int - albums albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Type_ibfk_1") - type type @relation(fields: [typeId], references: [id], onDelete: Cascade, map: "Album_Type_ibfk_2") + albumId Int + typeId Int + album albums @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "Album_Type_ibfk_1") + type type @relation(fields: [typeId], references: [id], onDelete: Cascade, map: "Album_Type_ibfk_2") @@id([albumId, typeId]) - @@index([typeId], map: "typeId") } model Game_Platform { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) gameSlug String @db.VarChar(255) platformId Int game game @relation(fields: [gameSlug], references: [slug], onDelete: Cascade, map: "Game_Platform_ibfk_1") platform platform @relation(fields: [platformId], references: [id], onDelete: Cascade, map: "Game_Platform_ibfk_2") @@id([gameSlug, platformId]) - @@index([platformId], map: "platformId") } model Publisher_Game { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) gameSlug String @db.VarChar(255) publisherId Int game game @relation(fields: [gameSlug], references: [slug], onDelete: Cascade, map: "Publisher_Game_ibfk_1") publisher publisher @relation(fields: [publisherId], references: [id], onDelete: Cascade, map: "Publisher_Game_ibfk_2") @@id([gameSlug, publisherId]) - @@index([publisherId], map: "publisherId") -} - -model SequelizeMeta { - name String @id @unique(map: "name") @db.VarChar(255) } model Series_Game { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - gameSlug String @db.VarChar(255) - seriesSlug String @db.VarChar(255) - game game @relation(fields: [gameSlug], references: [slug], onDelete: Cascade, map: "Series_Game_ibfk_1") - series series @relation(fields: [seriesSlug], references: [slug], onDelete: Cascade, map: "Series_Game_ibfk_2") + gameSlug String @db.VarChar(255) + seriesSlug String @db.VarChar(255) + game game @relation(fields: [gameSlug], references: [slug], onDelete: Cascade, map: "Series_Game_ibfk_1") + series series @relation(fields: [seriesSlug], references: [slug], onDelete: Cascade, map: "Series_Game_ibfk_2") @@id([gameSlug, seriesSlug]) - @@index([seriesSlug], map: "seriesSlug") } model Studio_Animation { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) animationId Int studioSlug String @db.VarChar(255) animation animation @relation(fields: [animationId], references: [id], onDelete: Cascade, map: "Studio_Animation_ibfk_1") studio studio @relation(fields: [studioSlug], references: [slug], onDelete: Cascade, map: "Studio_Animation_ibfk_2") @@id([animationId, studioSlug]) - @@index([studioSlug], map: "studioSlug") } model User_Role { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - userUsername String @db.VarChar(255) - roleName String @db.VarChar(255) - users users @relation(fields: [userUsername], references: [id], onDelete: Cascade, map: "User_Role_ibfk_1") - roles roles @relation(fields: [roleName], references: [name], onDelete: Cascade, map: "User_Role_ibfk_2") + userUsername String @db.VarChar(255) + roleName String @db.VarChar(255) + users users @relation(fields: [userUsername], references: [id], onDelete: Cascade, map: "User_Role_ibfk_1") + roles roles @relation(fields: [roleName], references: [name], onDelete: Cascade, map: "User_Role_ibfk_2") @@id([userUsername, roleName]) - @@index([roleName], map: "roleName") } model albumHistories { @@ -163,70 +123,64 @@ model albumHistories { updatedAt DateTime @db.DateTime(0) username String? @db.VarChar(255) albumId Int? - users users? @relation(fields: [username], references: [id], map: "albumHistories_ibfk_1") - albums albums? @relation(fields: [albumId], references: [id], map: "albumHistories_ibfk_2") - - @@index([albumId], map: "ostId") - @@index([username], map: "username") + user users? @relation(fields: [username], references: [id], map: "albumHistories_ibfk_1") + album albums? @relation(fields: [albumId], references: [id], map: "albumHistories_ibfk_2") } model albums { - id Int @id @default(autoincrement()) - title String? @db.VarChar(255) - subTitle String? @db.Text - releaseDate DateTime? @db.Date - label String? @db.VarChar(255) - vgmdb String? @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - description String? @db.VarChar(255) - createdBy String? @db.VarChar(255) - status String? @db.VarChar(255) - placeholder String? @db.Text - headerColor String? @default("#ffffff") @db.VarChar(255) - animList Album_Animation[] - artistList Album_Artist[] - categoryList Album_Category[] - classificationList Album_Classification[] - gameList Album_Game[] - platformList Album_Platform[] - Album_Type Album_Type[] - albumHistories albumHistories[] - availables availables[] - comments comments[] - discs discs[] - downloads downloads[] - favorites favorites[] - linkCategories linkCategories[] - ratings ratings[] - relatedAlbumList related_album[] @relation("related_album_albumIdToalbums") - relatedToAlbumList related_album[] @relation("related_album_relatedIdToalbums") - stores stores[] + id Int @id @default(autoincrement()) + title String? @db.VarChar(255) + subTitle String? @db.Text + releaseDate DateTime? @db.Date + label String? @db.VarChar(255) + vgmdb String? @db.VarChar(255) + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + description String? @db.VarChar(255) + createdBy String? @db.VarChar(255) + status String? @db.VarChar(255) + placeholder String? @db.Text + headerColor String? @default("#ffffff") @db.VarChar(255) + animations Album_Animation[] + artists Album_Artist[] + categories Album_Category[] + classifications Album_Classification[] + games Album_Game[] + platforms Album_Platform[] + types Album_Type[] + histories albumHistories[] + availables availables[] + comments comments[] + discs discs[] + downloads downloads[] + favorites favorites[] + linkCategories linkCategories[] + ratings ratings[] + relatedAlbums related_album[] @relation("related_album_albumIdToalbums") + relatedTo related_album[] @relation("related_album_relatedIdToalbums") + stores stores[] } model animation { - id Int @id @default(autoincrement()) - title String? @unique(map: "title") @db.VarChar(255) - releaseDate DateTime? @db.Date - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - studioSlug String? @db.VarChar(255) - subTitle String? @unique(map: "subTitle") @db.VarChar(255) - placeholder String? @db.Text - headerColor String? @default("#ffffff") @db.VarChar(255) - Album_Animation Album_Animation[] - Studio_Animation Studio_Animation[] - studio studio? @relation(fields: [studioSlug], references: [slug], map: "animation_ibfk_1") - - @@index([studioSlug], map: "studioSlug") + id Int @id @default(autoincrement()) + title String? @unique(map: "title") @db.VarChar(255) + releaseDate DateTime? @db.Date + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + studioSlug String? @db.VarChar(255) + subTitle String? @unique(map: "subTitle") @db.VarChar(255) + placeholder String? @db.Text + headerColor String? @default("#ffffff") @db.VarChar(255) + albums Album_Animation[] + studios Studio_Animation[] } model artist { - slug String @id @db.VarChar(255) - name String? @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - Album_Artist Album_Artist[] + slug String @id @db.VarChar(255) + name String? @db.VarChar(255) + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + albums Album_Artist[] } model availables { @@ -236,23 +190,21 @@ model availables { createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) albumId Int? - albums albums? @relation(fields: [albumId], references: [id], map: "availables_ibfk_1") - - @@index([albumId], map: "ostId") + album albums? @relation(fields: [albumId], references: [id], map: "availables_ibfk_1") } model category { - name String @id @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - Album_Category Album_Category[] + name String @id @db.VarChar(255) + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + albums Album_Category[] } model classification { - name String @id @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - Album_Classification Album_Classification[] + name String @id @db.VarChar(255) + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + classifications Album_Classification[] } model comments { @@ -263,11 +215,8 @@ model comments { updatedAt DateTime @db.DateTime(0) albumId Int? username String? @db.VarChar(255) - albums albums? @relation(fields: [albumId], references: [id], map: "comments_ibfk_1") - users users? @relation(fields: [username], references: [id], map: "comments_ibfk_2") - - @@index([albumId], map: "ostId") - @@index([username], map: "username") + album albums? @relation(fields: [albumId], references: [id], map: "comments_ibfk_1") + user users? @relation(fields: [username], references: [id], map: "comments_ibfk_2") } model config { @@ -283,10 +232,8 @@ model discs { body String? @db.Text createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) - albumId Int? - albums albums? @relation(fields: [albumId], references: [id], map: "discs_ibfk_1") - - @@index([albumId], map: "ostId") + albumId Int + album albums? @relation(fields: [albumId], references: [id], map: "discs_ibfk_1") } model downloads { @@ -295,24 +242,19 @@ model downloads { small Boolean? createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) - albumId Int? - albums albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "downloads_ibfk_1") + albumId Int + album albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "downloads_ibfk_1") links links[] - - @@index([albumId], map: "ostId") } model favorites { id Int @id @default(autoincrement()) createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) - albumId Int? + albumId Int username String? @db.VarChar(255) - albums albums? @relation(fields: [albumId], references: [id], map: "favorites_ibfk_1") + album albums? @relation(fields: [albumId], references: [id], map: "favorites_ibfk_1") users users? @relation(fields: [username], references: [id], map: "favorites_ibfk_2") - - @@index([albumId], map: "ostId") - @@index([username], map: "username") } model forgors { @@ -322,23 +264,21 @@ model forgors { createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) username String? @db.VarChar(255) - users users? @relation(fields: [username], references: [id], map: "forgors_ibfk_1") - - @@index([username], map: "username") + user users? @relation(fields: [username], references: [id], map: "forgors_ibfk_1") } model game { - slug String @id @db.VarChar(255) - name String? @db.VarChar(255) - releaseDate DateTime? @db.Date - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - placeholder String? @db.Text - headerColor String? @default("#ffffff") @db.VarChar(255) - Album_Game Album_Game[] - Game_Platform Game_Platform[] - Publisher_Game Publisher_Game[] - Series_Game Series_Game[] + slug String @id @db.VarChar(255) + name String? @db.VarChar(255) + releaseDate DateTime? @db.Date + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + placeholder String? @db.Text + headerColor String? @default("#ffffff") @db.VarChar(255) + albums Album_Game[] + platforms Game_Platform[] + publishers Publisher_Game[] + series Series_Game[] } model linkCategories { @@ -347,10 +287,8 @@ model linkCategories { small Boolean? createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) - albumId Int? - albums albums? @relation(fields: [albumId], references: [id], map: "linkCategories_ibfk_1") - - @@index([albumId], map: "ostId") + albumId Int + album albums? @relation(fields: [albumId], references: [id], map: "linkCategories_ibfk_1") } model links { @@ -361,11 +299,9 @@ model links { custom String? @db.VarChar(255) createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) - downloadId Int? + downloadId Int url2 String? @db.VarChar(255) - downloads downloads? @relation(fields: [downloadId], references: [id], map: "links_ibfk_1") - - @@index([downloadId], map: "downloadId") + download downloads? @relation(fields: [downloadId], references: [id], map: "links_ibfk_1") } model logs { @@ -375,9 +311,7 @@ model logs { createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) username String? @db.VarChar(255) - users users? @relation(fields: [username], references: [id], map: "logs_ibfk_1") - - @@index([username], map: "username") + user users? @relation(fields: [username], references: [id], map: "logs_ibfk_1") } model pendings { @@ -387,47 +321,41 @@ model pendings { } model platform { - id Int @id @default(autoincrement()) - name String? @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - type String? @default("Game") @db.VarChar(255) - Album_Platform Album_Platform[] - Game_Platform Game_Platform[] + id Int @id @default(autoincrement()) + name String? @db.VarChar(255) + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + type String? @default("Game") @db.VarChar(255) + albums Album_Platform[] + games Game_Platform[] } model publisher { - id Int @id @default(autoincrement()) - name String? @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - Publisher_Game Publisher_Game[] + id Int @id @default(autoincrement()) + name String? @db.VarChar(255) + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + games Publisher_Game[] } model ratings { id Int @id @default(autoincrement()) - score Int? + score Int createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) - albumId Int? - username String? @db.VarChar(255) - albums albums? @relation(fields: [albumId], references: [id], map: "ratings_ibfk_1") - users users? @relation(fields: [username], references: [id], map: "ratings_ibfk_2") - - @@index([albumId], map: "ostId") - @@index([username], map: "username") + albumId Int + username String @db.VarChar(255) + album albums? @relation(fields: [albumId], references: [id], map: "ratings_ibfk_1") + user users? @relation(fields: [username], references: [id], map: "ratings_ibfk_2") } model related_album { - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) albumId Int relatedId Int - pageAlbum albums @relation("related_album_albumIdToalbums", fields: [albumId], references: [id], onDelete: Cascade, map: "related_album_ibfk_1") - relatedAlbum albums @relation("related_album_relatedIdToalbums", fields: [relatedId], references: [id], onDelete: Cascade, map: "related_album_ibfk_2") + pageAlbum albums @relation("related_album_albumIdToalbums", fields: [albumId], references: [id], onDelete: Cascade, map: "related_album_ibfk_1") + relatedAlbum albums @relation("related_album_relatedIdToalbums", fields: [relatedId], references: [id], onDelete: Cascade, map: "related_album_ibfk_2") @@id([albumId, relatedId]) - @@index([relatedId], map: "relatedId") } model requests { @@ -451,7 +379,7 @@ model roles { permissions Json? createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) - User_Role User_Role[] + users User_Role[] } model series { @@ -461,7 +389,7 @@ model series { updatedAt DateTime @db.DateTime(0) placeholder String? @db.Text headerColor String? @default("#ffffff") @db.VarChar(255) - Series_Game Series_Game[] + games Series_Game[] } model stores { @@ -471,18 +399,15 @@ model stores { createdAt DateTime @db.DateTime(0) updatedAt DateTime @db.DateTime(0) albumId Int? - albums albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "stores_ibfk_1") - - @@index([albumId], map: "ostId") + album albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "stores_ibfk_1") } model studio { - slug String @id @db.VarChar(255) - name String? @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - Studio_Animation Studio_Animation[] - animation animation[] + slug String @id @db.VarChar(255) + name String? @db.VarChar(255) + createdAt DateTime @db.DateTime(0) + updatedAt DateTime @db.DateTime(0) + animations Studio_Animation[] } model submissions { @@ -496,19 +421,14 @@ model submissions { updatedAt DateTime @db.DateTime(0) userUsername String? @db.VarChar(255) requestId Int? - users users? @relation(fields: [userUsername], references: [id], map: "submissions_ibfk_1") - requests requests? @relation(fields: [requestId], references: [id], map: "submissions_ibfk_2") - - @@index([requestId], map: "requestId") - @@index([userUsername], map: "userUsername") + user users? @relation(fields: [userUsername], references: [id], map: "submissions_ibfk_1") + request requests? @relation(fields: [requestId], references: [id], map: "submissions_ibfk_2") } model type { - id Int @id @default(autoincrement()) - name String? @db.VarChar(255) - createdAt DateTime @db.DateTime(0) - updatedAt DateTime @db.DateTime(0) - Album_Type Album_Type[] + id Int @id @default(autoincrement()) + name String @db.VarChar(255) + albums Album_Type[] } model users { @@ -521,16 +441,16 @@ model users { updatedAt DateTime @db.DateTime(0) image String? @db.VarChar(255) - roleList User_Role[] - albumHistories albumHistories[] - comments comments[] - favorites favorites[] - forgors forgors[] - logs logs[] - ratings ratings[] - submissions submissions[] - sessions session[] - accounts account[] + roles User_Role[] + histories albumHistories[] + comments comments[] + favorites favorites[] + forgors forgors[] + logs logs[] + ratings ratings[] + submissions submissions[] + sessions session[] + accounts account[] } model session { diff --git a/src/components/sidebar/CommentCarousel.astro b/src/components/sidebar/CommentCarousel.astro index 7ffb15f..69f5a43 100644 --- a/src/components/sidebar/CommentCarousel.astro +++ b/src/components/sidebar/CommentCarousel.astro @@ -6,7 +6,7 @@ import SidebarSection from './SidebarSection.astro' import Looper from './CommentCarousel/Looper' const comments = await prismaClient.comments.findMany({ - select: { text: true, albums: { select: { id: true, title: true } } }, + select: { text: true, album: { select: { id: true, title: true } } }, orderBy: { createdAt: 'desc' }, take: 5 }) diff --git a/src/components/sidebar/CommentCarousel/Looper.tsx b/src/components/sidebar/CommentCarousel/Looper.tsx index e94102a..9c465cb 100644 --- a/src/components/sidebar/CommentCarousel/Looper.tsx +++ b/src/components/sidebar/CommentCarousel/Looper.tsx @@ -4,7 +4,7 @@ import { useEffect, useRef, useState, type ButtonHTMLAttributes, type ReactNode interface Props { comments: { text: string | null - albums: { + album: { id: number title: string | null } | null @@ -37,7 +37,7 @@ export default function Looper(props: Props) {
{comment.text}
- - {comment.albums?.title} + - {comment.album?.title}
{isMultiple ? (
diff --git a/src/middleware.ts b/src/middleware.ts index 00d5d17..e8c2ba5 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -14,10 +14,10 @@ export const onRequest = defineMiddleware(async (context, next) => { context.locals.session = isAuthed.session const user = await prismaClient.users.findUnique({ - select: { roleList: { select: { roles: { select: { permissions: true } } } } }, + select: { roles: { select: { roles: { select: { permissions: true } } } } }, where: { id: isAuthed.user.id } }) - const permissions = (user?.roleList.map((r) => r.roles.permissions).flat() as string[]) ?? [] + const permissions = (user?.roles.map((r) => r.roles.permissions).flat() as string[]) ?? [] const pages = PAGES.filter((p) => p.perms.some((r) => permissions.includes(r))).map((p) => p.url) context.locals.permissions = permissions diff --git a/src/pages/album/[id].astro b/src/pages/album/[id].astro index 75ef89e..5a786fb 100644 --- a/src/pages/album/[id].astro +++ b/src/pages/album/[id].astro @@ -21,12 +21,12 @@ const hasDirect = permissions.includes('SKIP_ADS') const album = await prismaClient.albums.findUnique({ where: { id: Number(id) }, include: { - artistList: { select: { artist: true } }, - categoryList: { select: { categoryName: true } }, - classificationList: { select: { classificationName: true } }, - platformList: { select: { platform: { select: { id: true, name: true } } } }, - gameList: { select: { game: { select: { slug: true, name: true } } } }, - animList: { select: { animation: { select: { id: true, title: true } } } }, + artists: { select: { artist: true } }, + categories: { select: { categoryName: true } }, + classifications: { select: { classificationName: true } }, + platforms: { select: { platform: { select: { id: true, name: true } } } }, + games: { select: { game: { select: { slug: true, name: true } } } }, + animations: { select: { animation: { select: { id: true, title: true } } } }, stores: { select: { url: true, provider: true }, where: { NOT: { provider: 'SOON' } } }, discs: { select: { number: true, body: true } }, downloads: { @@ -35,7 +35,7 @@ const album = await prismaClient.albums.findUnique({ links: { select: { id: true, url: true, url2: true, provider: true, directUrl: hasDirect } } } }, - relatedAlbumList: { select: { relatedAlbum: { select: { id: true, title: true } } } } + relatedAlbums: { select: { relatedAlbum: { select: { id: true, title: true } } } } } }) @@ -96,10 +96,10 @@ const { currentLocale } = Astro } { - (album?.artistList.length ?? 0) > 0 && ( + (album?.artists.length ?? 0) > 0 && ( {m.artists()} - {album?.artistList.map(({ artist }) => artist.name).join(', ')} + {album?.artists.map(({ artist }) => artist.name).join(', ')} ) } @@ -109,10 +109,8 @@ const { currentLocale } = Astro { [ - album?.categoryList - .map(({ categoryName }) => (m as any)[`${categoryName}Osts`]()) - .join(' & '), - album?.classificationList.map(({ classificationName }) => classificationName).join(', ') + album?.categories.map(({ categoryName }) => (m as any)[`${categoryName}Osts`]()).join(' & '), + album?.classifications.map(({ classificationName }) => classificationName).join(', ') ] .filter((f) => f !== '') .join(' - ') @@ -132,11 +130,11 @@ const { currentLocale } = Astro ) } { - (album?.platformList.length ?? 0) > 0 && ( + (album?.platforms.length ?? 0) > 0 && ( {m.platforms()} - {album?.platformList.map(({ platform }, i) => ( + {album?.platforms.map(({ platform }, i) => ( {id === '29' ? ( @@ -147,7 +145,7 @@ const { currentLocale } = Astro {platform.name} )} - {i !== album?.platformList.length - 1 && ', '} + {i !== album?.platforms.length - 1 && ', '} ))} @@ -155,16 +153,16 @@ const { currentLocale } = Astro ) } { - (album?.gameList.length ?? 0) > 0 && ( + (album?.games.length ?? 0) > 0 && ( {m.games()} - {album?.gameList.map(({ game }, i) => ( + {album?.games.map(({ game }, i) => ( {game.name} - {i !== album?.gameList.length - 1 && ', '} + {i !== album?.games.length - 1 && ', '} ))} @@ -172,16 +170,16 @@ const { currentLocale } = Astro ) } { - (album?.animList.length ?? 0) > 0 && ( + (album?.animations.length ?? 0) > 0 && ( {m.animations()} - {album?.animList.map(({ animation }, i) => ( + {album?.animations.map(({ animation }, i) => ( {animation.title} - {i !== album?.animList.length - 1 && ', '} + {i !== album?.animations.length - 1 && ', '} ))} @@ -343,7 +341,7 @@ const { currentLocale } = Astro
{ - album?.relatedAlbumList.map(({ relatedAlbum }) => ( + album?.relatedAlbums.map(({ relatedAlbum }) => ( a.artist.name).join(' - '), + description: album.subTitle || album.artists.map((a) => a.artist.name).join(' - '), link: `https://www.sittingonclouds.net/album/${album.id}`, customData: `=0.12 <1" esbuild-register "3.6.0" optionalDependencies: