feat(cms): MongoDB → PostgreSQL content transfer; fix two schema issues it found (MITHOME-136)

- scripts/transfer-content.ts: export (shared config + MongoDB adapter,
  locale 'all', drafts, upload files) and import (PostgreSQL, one transaction,
  refuses a non-empty target); pure helpers in src/lib/content-transfer.ts
- LegalPages: the section anchor is its own field; as the array row id it was
  a table-wide primary key in PostgreSQL and the two pages collided
- Products.status: own enumName; the default name equalled the drafts
  _status enum, so only draft/published were accepted
- baseline migration regenerated

Verified on a staging copy (disposable MongoDB + PostgreSQL on llmdev): counts
match, all 14 public pages (hu/en) render identical text, partner logo loads,
second import writes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Do Siki
2026-09-29 22:27:11 +02:00
co-authored by Claude Opus 5.5
parent e3ec6a9ac3
commit a68fb94b61
14 changed files with 500 additions and 50 deletions
+9 -1
View File
@@ -158,7 +158,8 @@ describe('Payload globals', () => {
// MITHOME-112: `slug` is the shared URL identifier of LegalPages.
// MITHOME-113: `result`/`notes` are legal-validation metadata, not copy.
// MITHOME-130: a product `name` is a brand, the same in every language.
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'address', 'slug', 'result', 'notes', 'name'])
// MITHOME-136: the legal section `anchor` (formerly its row `id`) is shared too.
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'anchor', 'address', 'slug', 'result', 'notes', 'name'])
type Node = FieldLike & { localized?: boolean; fields?: Node[] }
type Finding = { path: string; type?: string; localized: boolean }
@@ -285,6 +286,13 @@ describe('MITHOME-130 hosting plans', () => {
expect(slug).toMatchObject({ required: true, unique: true })
})
it('should give the lifecycle status its own PostgreSQL enum (MITHOME-136)', () => {
// Regression: the default enum name equals the drafts `_status` enum, and
// PostgreSQL then only accepted draft/published.
const status = findField(Products.fields, 'status') as unknown as { enumName?: string }
expect(status.enumName).toBe('enum_products_lifecycle_status')
})
it('should require a whole, non-negative net price and default to yearly billing', () => {
const net = findField(group('pricing'), 'netAmount') as unknown as FieldLike & { validate: Validate }
expect(net.required).toBe(true)