feat(cms): switch Payload to PostgreSQL with a fresh baseline migration (MITHOME-136)

- postgresAdapter (uuid ids, no push, prodMigrations), DATABASE_URI
- src/payload.shared.ts: the config without the db adapter, shared with the
  one-off MongoDB content transfer
- baseline migration 20260929_200306_initial (86 tables; applied twice on a
  disposable PostgreSQL 16: second run is a no-op)
- seed copy (references, hosting plans) moved to src/content/seeds/
- MongoDB data migrations, their helpers/tests and the dead lib/mongodb.ts
  removed (kept in git history)
- npm scripts for the Payload CLI (works now that the package is ESM)

Branch only: staging has no PostgreSQL yet (tasks 3.x).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Do Siki
2026-09-29 22:09:00 +02:00
co-authored by Claude Opus 5.5
parent a3d6cbe404
commit e3ec6a9ac3
40 changed files with 14226 additions and 2160 deletions
+18 -72
View File
@@ -1,9 +1,10 @@
/**
* Payload CMS configuration (MITHOME-86 — alapinstalláció).
*
* WHY a saját MongoDB kapcsolatot használjuk: a projekt már MongoDB-t futtat
* (proto/src/lib/mongodb.ts) — Payload a `mongooseAdapter`-en keresztül
* ugyanabba az adatbázisba ír, nincs szükség külön DB-re/szerverre.
* MITHOME-136: PostgreSQL (`postgresAdapter`) — a platform egy PostgreSQL-
* szervert használ, a weboldal saját adatbázissal (mitplatform ADR-0001).
* A MongoDB-korszak adatmigrációi a git-előzményben vannak; a tartalom
* egyszeri átvitele: scripts/transfer-content.ts.
*
* MITHOME-87: Home/About/Services/Contact/Common Globals hozzáadva — ezek
* tükrözik a proto/src/content/pages/*.json + common.json struktúráját.
@@ -21,82 +22,27 @@
* nyers, Payload-on kívüli Mongo collection-be (`contact_submissions`,
* proto/src/lib/mongodb.ts) írt, amit az ügyfél nem látott sehol az admin
* felületen. Mostantól Payload collection, a route.ts a Local API-n ír bele.
* MITHOME-111: a Globals fordítható mezői lokalizáltak; a meglévő adatot a
* src/migrations/20260929_localize_globals.ts alakítja át (prodMigrations).
* MITHOME-111: a Globals fordítható mezői lokalizáltak.
* MITHOME-130: Products collection + HostingPlans global (tárhelycsomagok).
*/
import path from 'path'
import { fileURLToPath } from 'url'
import { buildConfig } from 'payload'
import { mongooseAdapter } from '@payloadcms/db-mongodb'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import sharp from 'sharp'
import { postgresAdapter } from '@payloadcms/db-postgres'
import { Users } from './collections/Users'
import { LegalPages } from './collections/LegalPages'
import { Media } from './collections/Media'
import { Partners } from './collections/Partners'
import { ContactSubmissions } from './collections/ContactSubmissions'
import { Products } from './collections/Products'
import { Home } from './globals/Home'
import { About } from './globals/About'
import { Services } from './globals/Services'
import { Contact } from './globals/Contact'
import { Common } from './globals/Common'
import { HostingPlans } from './globals/HostingPlans'
import { sharedConfig } from './payload.shared'
import { migrations } from './migrations'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
export default buildConfig({
// Admin felület — bejelentkezés az Users collection-nel. Access control /
// jelszó-politika: MITHOME-90 (src/collections/Users.ts).
admin: {
user: Users.slug,
components: {
// MITHOME-120: gyorskeresés minden admin oldal tetején.
// WHY 'src/...' és nem './components/...': a Payload komponens-útvonal
// az admin.importMap.baseDir-hez relatív, ami alapértelmezésben
// process.cwd() (a `generate:importmap` a proto/ mappából fut, NEM a
// payload.config.ts mappájából).
header: ['./src/components/admin/QuickSearch#QuickSearch'],
},
},
editor: lexicalEditor(),
collections: [Users, LegalPages, Media, Partners, ContactSubmissions, Products],
globals: [Home, About, Services, Contact, Common, HostingPlans],
// MITHOME-109/110: hu alapértelmezett (URL-prefix nélkül), en /en/ alatt
// (Next.js routing oldala: MITHOME-114). fallback:true -> amíg egy mezőnek
// nincs angol fordítása, a magyar érték jelenik meg — nem üres oldal.
localization: {
locales: ['hu', 'en'],
defaultLocale: 'hu',
fallback: true,
},
secret: process.env.PAYLOAD_SECRET || '',
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
db: mongooseAdapter({
url: process.env.MONGODB_URI || '',
// MITHOME-111: pending migrations run automatically on production
// startup (NODE_ENV=production — staging + prod containers), so a deploy
// never serves the localized schema on un-migrated data.
...sharedConfig,
db: postgresAdapter({
pool: { connectionString: process.env.DATABASE_URI || '' },
// WHY uuid: opaque ids that do not reveal record counts and never clash
// when content is transferred or joined with the catalogue (PLATFM-15).
idType: 'uuid',
// WHY no push: the schema changes only through migrations, the same way
// locally, on staging and in production.
push: false,
// Pending migrations run automatically on production-mode startup
// (staging + prod containers) before the site serves requests.
prodMigrations: migrations,
}),
// WHY: Payload sends anonymous usage telemetry to its own servers by
// default — GDPR-tudatosan kikapcsolva, mivel a projekt self-hosted és
// az ügyfél adatai nem hagyhatják el a saját infrastruktúránkat.
telemetry: false,
sharp,
})