feat(backend): update collections, config and migration tools

Update Payload CMS configuration, collections (Audit, Posts), and add migration scripts/reports.
This commit is contained in:
2026-02-11 11:50:23 +08:00
parent 8ca609a889
commit be7fc902fb
46 changed files with 5442 additions and 15 deletions

View File

@@ -8,13 +8,16 @@ import { logDocumentChange } from '@/utilities/auditLogger'
*/
export const auditChange =
(collection: string): AfterChangeHook =>
async ({ doc, req }) => {
async ({ doc, req, context }) => {
// 跳過 audit 集合本身以避免無限循環
if (collection === 'audit') return doc
// Determine operation from context or default to 'update'
const operation = (context?.operation as 'create' | 'update' | 'delete') || 'update'
await logDocumentChange(
req,
operation as 'create' | 'update' | 'delete',
operation,
collection,
doc.id as string,
(doc.title || doc.name || String(doc.id)) as string,

View File

@@ -111,7 +111,7 @@ export const Posts: CollectionConfig<'posts'> = {
},
}),
label: false,
required: true,
required: false, // Temporarily disabled for migration
},
{
name: 'excerpt',