fix: make category slug optional

This commit is contained in:
Kailasdevdas
2026-05-18 10:58:14 +05:30
parent 8d60afdc49
commit d92e0538bd
3 changed files with 6 additions and 2 deletions
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "HealthCheckCategory" ALTER COLUMN "slug" DROP NOT NULL;
+1 -1
View File
@@ -224,7 +224,7 @@ model NewsImage {
model HealthCheckCategory {
id Int @id @default(autoincrement())
name String @unique
slug String @unique
slug String? @unique
description String?
isActive Boolean @default(true)
sortOrder Int @default(1000)
@@ -28,7 +28,7 @@ export const createCategory = async (req, res) => {
const category = await prisma.healthCheckCategory.create({
data: {
name,
slug,
slug: slug || null,
description,
isActive: isActive ?? true,
sortOrder: sortOrder ? Number(sortOrder) : 1000,
@@ -58,6 +58,8 @@ export const updateCategory = async (req, res) => {
if (data.sortOrder !== undefined) data.sortOrder = Number(data.sortOrder);
if (data.slug === "") data.slug = null;
const updatedCategory = await prisma.$transaction(async (tx) => {
const category = await tx.healthCheckCategory.update({
where: { id: Number(id) },