proclamation-categories: sub-category management inline in parent form
- Registry: Remove 'parent.name' from listFields (all shown records are top-level with no parent), remove 'parent: true' from include since unused - +page.server.ts: Custom load filters to parentId=null (top-level only); custom upsert syncs children (create/update/delete) and handles P2002 duplicate-name errors; custom delete cascades to children first to avoid FK constraint violations - CategoryForm.svelte: Replace parentId select dropdown with dynamic list of sub-category inputs. Each row has a name field and Remove button. Pre-populates from record.children when editing existing categories. Add Sub-category button appends new rows - +page.svelte: Remove unused relationOptionsData prop from CategoryForm; rename submit button label from 'Update' to 'Save' - prisma: Add ProclamationCategorySubscriptionLevel join table migration and regenerate client - General: Update TipTap mock, Toast, license-keys page, proclamations server/route tests, README, AGENTS.md, and other admin forms
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
-- DropIndex
|
||||
DROP INDEX "Proclamation_subscriptionLevelId_idx";
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "Proclamation" ALTER COLUMN "subscriptionLevelId" DROP DEFAULT;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "ProclamationCategorySubscriptionLevel" (
|
||||
"categoryId" INTEGER NOT NULL,
|
||||
"subscriptionLevelId" INTEGER NOT NULL,
|
||||
|
||||
CONSTRAINT "ProclamationCategorySubscriptionLevel_pkey" PRIMARY KEY ("categoryId","subscriptionLevelId")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProclamationCategorySubscriptionLevel" ADD CONSTRAINT "ProclamationCategorySubscriptionLevel_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "ProclamationCategory"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ProclamationCategorySubscriptionLevel" ADD CONSTRAINT "ProclamationCategorySubscriptionLevel_subscriptionLevelId_fkey" FOREIGN KEY ("subscriptionLevelId") REFERENCES "SubscriptionLevel"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
+22
-12
@@ -124,10 +124,8 @@ model Proclamation {
|
||||
categoryId Int
|
||||
category ProclamationCategory @relation(fields: [categoryId], references: [id])
|
||||
userProclamations UserProclamations[]
|
||||
subscriptionLevelId Int @default(1)
|
||||
subscriptionLevelId Int // Keeping old FK for migration stability
|
||||
subscriptionLevel SubscriptionLevel @relation(fields: [subscriptionLevelId], references: [id])
|
||||
|
||||
@@index(subscriptionLevelId)
|
||||
}
|
||||
|
||||
model UserProclamations {
|
||||
@@ -149,16 +147,27 @@ model SolfeggioFrequency {
|
||||
}
|
||||
|
||||
model ProclamationCategory {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
parentId Int?
|
||||
parent ProclamationCategory? @relation("CategoryHierarchy", fields: [parentId], references: [id])
|
||||
children ProclamationCategory[] @relation("CategoryHierarchy")
|
||||
proclamations Proclamation[]
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
parentId Int?
|
||||
parent ProclamationCategory? @relation("CategoryHierarchy", fields: [parentId], references: [id])
|
||||
children ProclamationCategory[] @relation("CategoryHierarchy")
|
||||
proclamations Proclamation[]
|
||||
subscriptionLevels ProclamationCategorySubscriptionLevel[]
|
||||
|
||||
@@unique([parentId, name])
|
||||
}
|
||||
|
||||
// Join table for ProclamationCategory -> SubscriptionLevel defaults
|
||||
model ProclamationCategorySubscriptionLevel {
|
||||
categoryId Int
|
||||
category ProclamationCategory @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
||||
subscriptionLevelId Int
|
||||
subscriptionLevel SubscriptionLevel @relation(fields: [subscriptionLevelId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([categoryId, subscriptionLevelId])
|
||||
}
|
||||
|
||||
model LicenseKey {
|
||||
id String @id @default(uuid())
|
||||
key String @unique
|
||||
@@ -169,8 +178,9 @@ model LicenseKey {
|
||||
}
|
||||
|
||||
model SubscriptionLevel {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
description String?
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
description String?
|
||||
proclamations Proclamation[]
|
||||
categoryLevels ProclamationCategorySubscriptionLevel[]
|
||||
}
|
||||
Reference in New Issue
Block a user