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
+6 -4
View File
@@ -17,9 +17,8 @@ import { legalValidationGroup } from './fields/legalValidation'
* nem vezetünk be külön szerializációt egy még nem létező render-rétegért.
*
* MITHOME-112 lokalizáció: a cím, a dátumszöveg és a szakaszok címe/tartalma
* lokalizált; a `slug` (URL-azonosító) és a szakasz-`id` közös, a `sections`
* tömb maga is közös (sorrend nyelvenként azonos). A meglévő adatot a
* src/migrations/20260929_localize_legal_pages.ts alakítja át.
* lokalizált; a `slug` (URL-azonosító) és a szakasz-`anchor` közös, a `sections`
* tömb maga is közös (sorrend nyelvenként azonos).
*/
export const LegalPages: CollectionConfig = {
slug: 'legal-pages',
@@ -53,7 +52,10 @@ export const LegalPages: CollectionConfig = {
type: 'array',
required: true,
fields: [
{ name: 'id', type: 'text', required: true },
// MITHOME-136: the section anchor is its own field. It used to be the
// array row `id`, which PostgreSQL stores as a table-wide primary key,
// so two pages with the same anchor ("bevezetes") collided.
{ name: 'anchor', type: 'text', required: true, admin: { description: 'A szakasz horgonya (pl. bevezetes), minden nyelven azonos.' } },
{ name: 'title', type: 'text', required: true, localized: true },
{ name: 'content', type: 'textarea', required: true, localized: true },
],
+4
View File
@@ -62,6 +62,10 @@ export const Products: CollectionConfig = {
name: 'status',
label: 'Életciklus-állapot',
type: 'select',
// MITHOME-136: own PostgreSQL enum name. The default "enum_products_status"
// is also Payload's name for the drafts `_status` enum, so the two
// collided and only draft/published were accepted.
enumName: 'enum_products_lifecycle_status',
required: true,
defaultValue: 'draft',
options: PRODUCT_STATUSES.map((value) => ({ label: PRODUCT_STATUS_LABELS[value], value })),