fix(seed): guard home-page update by checking existing content
Some checks are pending
CI / Type Check (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Unit Tests (push) Waiting to run
Deploy / Build & Push Image (push) Waiting to run
Deploy / Deploy to VPS (push) Blocked by required conditions

Avoids invalid relationship errors when home-page already has data.
Only updates home-page on first seed when hero is absent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vadym Samoilenko 2026-05-18 13:29:58 +01:00
parent 1f752a57b0
commit c07fd6913c

View file

@ -344,9 +344,9 @@ export async function POST(req: NextRequest) {
'Hero family silhouette'
)
// Skip home-page update if media files are unavailable (Docker prod container)
const homePageOk = heroBg1Media || wpMediaIds.some(Boolean) || galleryMediaIds.some(Boolean)
if (homePageOk) {
const existingHomePage = await payload.findGlobal({ slug: 'home-page', overrideAccess: true })
const homePageNeedsUpdate = !(existingHomePage as Record<string, unknown>)?.['hero']
if (homePageNeedsUpdate) {
await payload.updateGlobal({
slug: 'home-page',
data: {
@ -433,7 +433,7 @@ export async function POST(req: NextRequest) {
})
results.push('Seeded home-page global')
} else {
results.push('home-page: media not available, skipping update')
results.push('home-page: already has content, skipping update')
}
// === HEADER ===