Implement album stores field
Some checks failed
/ build (push) Has been cancelled

This commit is contained in:
Jorge Vargas 2025-04-07 14:50:47 -06:00
parent 63affb6b7f
commit 60a3ef3541
4 changed files with 18 additions and 8 deletions

View file

@ -0,0 +1,10 @@
/*
Warnings:
- You are about to drop the column `createdAt` on the `stores` table. All the data in the column will be lost.
- You are about to drop the column `updatedAt` on the `stores` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE `stores` DROP COLUMN `createdAt`,
DROP COLUMN `updatedAt`;

View file

@ -369,13 +369,11 @@ model series {
} }
model stores { model stores {
id Int @id @default(autoincrement()) id Int @id @default(autoincrement())
url String? @db.VarChar(255) url String? @db.VarChar(255)
provider String? @db.VarChar(255) provider String? @db.VarChar(255)
createdAt DateTime @db.DateTime(0) albumId Int?
updatedAt DateTime @db.DateTime(0) album albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "stores_ibfk_1")
albumId Int?
album albums? @relation(fields: [albumId], references: [id], onDelete: Cascade, map: "stores_ibfk_1")
} }
model studio { model studio {

View file

@ -53,6 +53,7 @@ export const POST: APIRoute = async ({ request, locals }) => {
platforms: { create: body.platforms.map((id) => ({ platform: { connect: { id } } })) }, platforms: { create: body.platforms.map((id) => ({ platform: { connect: { id } } })) },
// albumHistories // albumHistories
discs: { createMany: { data: body.discs } }, discs: { createMany: { data: body.discs } },
stores: { createMany: { data: body.stores } },
relatedAlbums: { create: body.related.map((id) => ({ relatedAlbum: { connect: { id } } })) } relatedAlbums: { create: body.related.map((id) => ({ relatedAlbum: { connect: { id } } })) }
}, },
include: { artists: { include: { artist: { select: { name: true } } } } } include: { artists: { include: { artist: { select: { name: true } } } } }

View file

@ -60,7 +60,8 @@ export const POST: APIRoute = async ({ request, locals }) => {
platforms: { deleteMany: {}, create: platforms?.map((id) => ({ platform: { connect: { id } } })) }, platforms: { deleteMany: {}, create: platforms?.map((id) => ({ platform: { connect: { id } } })) },
discs: { deleteMany: {}, createMany: { data: body.discs ?? [] } }, discs: { deleteMany: {}, createMany: { data: body.discs ?? [] } },
relatedAlbums: { deleteMany: {}, create: related?.map((id) => ({ relatedAlbum: { connect: { id } } })) }, relatedAlbums: { deleteMany: {}, create: related?.map((id) => ({ relatedAlbum: { connect: { id } } })) },
downloads: { deleteMany: {} } downloads: { deleteMany: {} },
stores: stores ? { deleteMany: {}, createMany: { data: stores } } : undefined
} }
}) })