Rebuild admin pages around DataTable/AdminModal; restructure categories/groups and v2 groups API
Remove the generic $lib/svelte-admin CRUD layer and AdminTable.svelte; each admin route now owns its own form/modal logic. Add DataTable.svelte, superform-errors.ts, and profile-specific modal/field components. Flatten proclamation categories/groups and drop subscription levels; add the v2 groups API; update v1/v2 endpoints, serializers, auth, and regenerated Prisma client with the new migrations. Document the overhaul plan in docs/ADMIN_OVERHAUL.md.
This commit is contained in:
+62
-45
@@ -25,7 +25,7 @@ model User {
|
||||
role UserRole? @relation(fields: [roleId], references: [id])
|
||||
sessions Session[]
|
||||
accounts Account[]
|
||||
profile Profile?
|
||||
profiles Profile[]
|
||||
licenseKeys LicenseKey[]
|
||||
userProclamations UserProclamations[]
|
||||
|
||||
@@ -37,28 +37,32 @@ model User {
|
||||
// a bunch of time trying to figure out how to customize the default Better-Auth model.
|
||||
model Profile {
|
||||
id String @id @default(uuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
userId String?
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
email String?
|
||||
firstName String
|
||||
lastName String
|
||||
phoneNumber String
|
||||
ghlContactId String? @map("ghl_contact_id")
|
||||
addresses Address[]
|
||||
|
||||
@@index([userId])
|
||||
@@index([email])
|
||||
}
|
||||
|
||||
model Address {
|
||||
id String @id @default(uuid())
|
||||
profileId String
|
||||
profile Profile @relation(fields: [profileId], references: [id], onDelete: Cascade)
|
||||
street String
|
||||
city String
|
||||
state String
|
||||
postalCode String
|
||||
country String
|
||||
type String @default("Mailing")
|
||||
isDefaultMailing Boolean @default(false)
|
||||
isDefaultBilling Boolean @default(false)
|
||||
isDefaultShipping Boolean @default(false)
|
||||
id String @id @default(uuid())
|
||||
profileId String
|
||||
profile Profile @relation(fields: [profileId], references: [id], onDelete: Cascade)
|
||||
street String
|
||||
city String
|
||||
state String
|
||||
postalCode String
|
||||
country String
|
||||
type String @default("Mailing")
|
||||
isDefaultMailing Boolean @default(false)
|
||||
isDefaultBilling Boolean @default(false)
|
||||
isDefaultShipping Boolean @default(false)
|
||||
}
|
||||
|
||||
model Session {
|
||||
@@ -123,9 +127,16 @@ model Proclamation {
|
||||
solfeggioFrequency SolfeggioFrequency @relation(fields: [solfeggioFrequencyId], references: [id])
|
||||
categoryId Int
|
||||
category ProclamationCategory @relation(fields: [categoryId], references: [id])
|
||||
groupId Int
|
||||
group ProclamationGroup @relation(fields: [groupId], references: [id])
|
||||
userProclamations UserProclamations[]
|
||||
subscriptionLevelId Int // Keeping old FK for migration stability
|
||||
subscriptionLevel SubscriptionLevel @relation(fields: [subscriptionLevelId], references: [id])
|
||||
}
|
||||
|
||||
model ProclamationGroup {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
sortOrder Int @default(0)
|
||||
proclamations Proclamation[]
|
||||
}
|
||||
|
||||
model UserProclamations {
|
||||
@@ -142,40 +153,54 @@ model UserProclamations {
|
||||
model SolfeggioFrequency {
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
value Int @unique
|
||||
value Int @unique
|
||||
proclamations Proclamation[]
|
||||
}
|
||||
|
||||
model ProclamationCategory {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
sortOrder Int @default(0)
|
||||
parentId Int?
|
||||
parent ProclamationCategory? @relation("CategoryHierarchy", fields: [parentId], references: [id])
|
||||
children ProclamationCategory[] @relation("CategoryHierarchy")
|
||||
proclamations Proclamation[]
|
||||
subscriptionLevels ProclamationCategorySubscriptionLevel[]
|
||||
|
||||
@@unique([parentId, name])
|
||||
id Int @id @default(autoincrement())
|
||||
name String @unique
|
||||
sortOrder Int @default(0)
|
||||
proclamations Proclamation[]
|
||||
}
|
||||
|
||||
// Join table for ProclamationCategory -> SubscriptionLevel defaults
|
||||
model ProclamationCategorySubscriptionLevel {
|
||||
categoryId Int
|
||||
category ProclamationCategory @relation(fields: [categoryId], references: [id], onDelete: Cascade)
|
||||
// Archive of the former child sub-categories removed when the
|
||||
// ProclamationCategory hierarchy was flattened. Kept for recovery/audit.
|
||||
// `@@ignore` keeps it out of the generated client while Prisma remains aware
|
||||
// of the table so `migrate dev` does not report it as an untracked table.
|
||||
model ProclamationCategoryLegacy {
|
||||
id Int @id
|
||||
name String
|
||||
parentId Int?
|
||||
sortOrder Int @default(0)
|
||||
|
||||
@@map("ProclamationCategoryLegacy")
|
||||
@@ignore
|
||||
}
|
||||
|
||||
// Archive of the category->subscription-level mappings for the child
|
||||
// categories removed when the category hierarchy was flattened. Kept with
|
||||
// `@@ignore` so Prisma remains aware of the table but it is excluded from the
|
||||
// generated client and Prisma's own migrations.
|
||||
model ProclamationCategorySubscriptionLevelLegacy {
|
||||
categoryId Int
|
||||
subscriptionLevelId Int
|
||||
subscriptionLevel SubscriptionLevel @relation(fields: [subscriptionLevelId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@id([categoryId, subscriptionLevelId])
|
||||
@@map("ProclamationCategorySubscriptionLevelLegacy")
|
||||
@@ignore
|
||||
}
|
||||
|
||||
model LicenseKey {
|
||||
id String @id @default(uuid())
|
||||
key String @unique
|
||||
active Boolean
|
||||
level String
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
userId String?
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
email String?
|
||||
|
||||
@@index([userId])
|
||||
@@index([email])
|
||||
}
|
||||
|
||||
model ApiKey {
|
||||
@@ -187,14 +212,6 @@ model ApiKey {
|
||||
revokedAt DateTime?
|
||||
}
|
||||
|
||||
model SubscriptionLevel {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
description String?
|
||||
proclamations Proclamation[]
|
||||
categoryLevels ProclamationCategorySubscriptionLevel[]
|
||||
}
|
||||
|
||||
// Portal-editable 7-color palette per canonical solfeggio frequency id (1-9).
|
||||
// `solfeggioFrequencyId` is the canonical id the kiosk uses (see
|
||||
// v2-serializers.ts), not the DB autoincrement id of `SolfeggioFrequency`.
|
||||
@@ -203,4 +220,4 @@ model ColorPalette {
|
||||
colors Json // ["#RRGGBB", ... x7]
|
||||
|
||||
@@map("ColorPalette")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user