fix(cms): Home usps/items key is its own field, not the row primary key (MITHOME-138)
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
CI Pipeline with Test Management / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🧪 Run Tests & Generate Reports (push) Canceled after 0s
CI Pipeline with Test Management / 🐳 Docker Integration Tests (push) Canceled after 0s
CI Pipeline with Test Management / 🏗️ Build Docker Image (push) Canceled after 0s
CI Pipeline with Test Management / 📊 Generate Test Summary (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 📊 Analyze Test Coverage (push) Canceled after 0s
Test Reporting & Gherkin Analysis / 🔄 Sync with Linear (push) Canceled after 0s
Test Reporting & Gherkin Analysis / ⚡ Performance Monitoring (push) Canceled after 0s
The editable id of the Home usps/items rows was also the row's primary key in PostgreSQL (a duplicate would fail to save; new rows needed a manual id). It is now the `key` field; migration 20260929_213538_home_row_keys adds the column and backfills it (main tables from id, version tables from _uuid). Tried on the staging pg_dump: keys backfilled, second run no-op, all 14 public pages unchanged. React keys use `key`; the transfer upgrades old bundles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
244553a665
commit
4a263586aa
@@ -169,6 +169,7 @@ Cél: a weboldal magyar (alapértelmezett, prefix nélkül, pl. `/rolunk`) és a
|
||||
| MITHOME-135 | Mentési megőrzés 14 napra a weboldalon (a salutem kapacitásának ellenőrzése után) | 📋 |
|
||||
| MITHOME-136 | A weboldal adatbázisának átállítása MongoDB-ről PostgreSQL-re (élesítés előtt) | 🔄 staging átállt, tesztek zöldek; hátra: a MongoDB kivezetése a következő kiadással |
|
||||
| MITHOME-137 | Port-ellenőrzés minden portdefiníció előtt (deploy és eldobható konténerek) | ✅ |
|
||||
| MITHOME-138 | Home: a usps/items sorok szerkeszthető azonosítója külön `key` mezőbe | 🔄 kész a main-en, staging deployra vár |
|
||||
| MITHOME-24 | Performance optimalizálás | 📋 |
|
||||
| MITHOME-25 | Reszponzív design finomítása | 📋 |
|
||||
| MITHOME-26 | Analytics integráció (Plausible / GA4) | 📋 |
|
||||
@@ -225,6 +226,7 @@ docker-compose -f docker-compose.dev.yml down
|
||||
## Frissítési Napló
|
||||
- **2026-09-29**: Staging deploy (`3a8b2eb`). Mentés: `~/backups/mozdit-staging-20260929-182546-pre-mithome-133.archive`. 459 unit teszt, az indexelhetőségi őr és 10/10 smoke zöld. A `20260929_atlantisz_pending` lefutott: az Atlantisz „Egyeztetés alatt” állapotban van (MITHOME-133), a főoldalon csak az Angele látszik.
|
||||
- **2026-09-29**: Atlantisz logó: a honlapjukról letöltött `atlantisz_logo.png` felirata fehér (sötét fejléchez készült), a mi világos oldalunkon olvashatatlan, és a logón álló név („Pihenőpark & Halásztanya”) eltér az admin-bejegyzéstől. Felhasználói döntés: később rendezzük, addig **pending** (egyeztetés alatt). A partner_references migráció a még le nem futott környezetekben pendinggel sorol be; a stagingre a `20260929_atlantisz_pending` követő migráció állítja át (a következő deploykor). Új ticket: MITHOME-133.
|
||||
- **2026-09-29**: MITHOME-138 kész (main, staging deploy még nem történt). A Home `about.usps` és `services.items` szerkeszthető `id`-ja külön `key` mezőbe került (PostgreSQL-ben a sor elsődleges kulcsa volt). A `20260929_213538_home_row_keys` migráció kézzel írt kitöltéssel másolja át az értékeket (fő tábla: `id`, verziótábla: `_uuid`). A staging `pg_dump`-ján próbálva: a kulcsok átkerültek, a második futás 0 lépés, a 14 publikus oldal szövege változatlan. A React-kulcsok a stabil `key`-re álltak.
|
||||
- **2026-09-29**: MITHOME-136 3.3: az integrációs (13/13) és az e2e (9/9) tesztek zöldek egy élő, PostgreSQL-es dev stacken az llmdev-en (`2166ab5`); egy elavult e2e-elvárás javítva. A MongoDB kivezetése (4.3) a tulajdonos döntése szerint a következő kiadással megy.
|
||||
- **2026-09-29**: MITHOME-136: a staging átállt PostgreSQL-re (`fe5594b`). Lépések: `POSTGRES_PASSWORD` generálva a szerveren (a `.env.staging` előtte mentve), export a futó staging MongoDB-ből, deploy (az app lefuttatta a kiinduló migrációt), import egy tranzakcióban, majd egy második, teljes deploy. Eredmény: a 14 publikus oldal szövege betűre egyezik az átállás előtti állapottal, a logó betölt, 11/11 smoke zöld, az admin (`ADMIN_EMAIL`) létrejött. Mentések: `~/backups/mozdit-staging-20260929-224411-pre-deploy.archive` (MongoDB), `…-225431-pre-deploy.pgdump`. A MongoDB-konténer egy kiadásig visszaútként marad.
|
||||
- **2026-09-29**: MITHOME-137 kiadva stagingre (`66b169c`). A port-ellenőrzés élesben lefutott a build előtt. Mentés: `~/backups/mozdit-staging-20260929-214434-pre-mithome-137.archive`. 516 unit teszt, az indexelhetőségi őr és 11/11 smoke zöld.
|
||||
|
||||
@@ -73,10 +73,12 @@ function buildHomeData(json: typeof homeJson) {
|
||||
trustBullets: toStringArray(hero.trustBullets),
|
||||
cta: { primary: toCtaLink(hero.cta.primary), secondary: toCtaLink(hero.cta.secondary) },
|
||||
},
|
||||
about,
|
||||
// MITHOME-138: the JSON `id` is the row key, not the row id.
|
||||
about: { ...about, usps: about.usps.map(({ id, ...usp }) => ({ key: id, ...usp })) },
|
||||
services: {
|
||||
...services,
|
||||
items: services.items.map((item) => ({
|
||||
items: services.items.map(({ id, ...item }) => ({
|
||||
key: id,
|
||||
...item,
|
||||
features: toStringArray(item.features),
|
||||
})),
|
||||
|
||||
@@ -155,8 +155,9 @@ async function importBundle(file: string) {
|
||||
}
|
||||
|
||||
for (const g of globals) {
|
||||
const entry = bundle.globals[g.slug]
|
||||
if (!entry) continue
|
||||
const raw = bundle.globals[g.slug]
|
||||
if (!raw) continue
|
||||
const entry: BundleDoc = { published: upgradeDoc(g.slug, raw.published), ...(raw.draft ? { draft: upgradeDoc(g.slug, raw.draft) } : {}) }
|
||||
const slug = g.slug as GlobalSlug
|
||||
const status = hasDrafts(g) ? { _status: 'published' } : {}
|
||||
for (const locale of LOCALES) {
|
||||
|
||||
@@ -57,7 +57,7 @@ export default async function LocaleLayout({
|
||||
contactEmail={siteConfig.contact.email}
|
||||
footerAddress={common.footer.address}
|
||||
footerCopyright={common.footer.copyright}
|
||||
homeServices={home.services.items.map((item) => ({ id: item.id, title: item.title, icon: item.icon }))}
|
||||
homeServices={home.services.items.map((item) => ({ id: item.key, title: item.title, icon: item.icon }))}
|
||||
locale={locale}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -116,7 +116,7 @@ export default function HomeView({ content: pageContent, partners, locale }: Hom
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 stagger-children">
|
||||
{(pageContent.about.usps ?? []).map((usp, index) => (
|
||||
<div
|
||||
key={usp.id}
|
||||
key={usp.key}
|
||||
className="group text-center p-6 rounded-xl transition-all duration-300 hover-lift animate-fade-in-up"
|
||||
style={{
|
||||
background: 'var(--color-background)',
|
||||
@@ -167,7 +167,7 @@ export default function HomeView({ content: pageContent, partners, locale }: Hom
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-8 max-w-5xl mx-auto">
|
||||
{pageContent.services.items.map((service, index) => (
|
||||
<div
|
||||
key={service.id}
|
||||
key={service.key}
|
||||
className="group card hover-lift"
|
||||
style={{ animationDelay: `${index * 100}ms` }}
|
||||
>
|
||||
|
||||
@@ -30,7 +30,7 @@ export default function ServicesView({ content: pageContent, homeServices, featu
|
||||
<section className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-8">
|
||||
{homeServices.map((service) => (
|
||||
<div key={service.id} className="bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-gray-200 dark:border-slate-700 p-8 hover:shadow-md transition-shadow">
|
||||
<div key={service.key} className="bg-white dark:bg-slate-800 rounded-xl shadow-sm border border-gray-200 dark:border-slate-700 p-8 hover:shadow-md transition-shadow">
|
||||
<div className="w-16 h-16 bg-blue-100 dark:bg-blue-900/40 rounded-lg flex items-center justify-center mb-6">
|
||||
<span className="text-2xl">{service.icon}</span>
|
||||
</div>
|
||||
|
||||
@@ -55,7 +55,8 @@ export const Home: GlobalConfig = {
|
||||
name: 'usps',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{ name: 'id', type: 'text', required: true },
|
||||
// MITHOME-138: own field; as the row `id` it was the row's primary key.
|
||||
{ name: 'key', type: 'text', required: true, admin: { description: 'Rövid, egyedi azonosító (pl. hosting).' } },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'description', type: 'textarea', required: true, localized: true },
|
||||
{ name: 'icon', type: 'text', required: true },
|
||||
@@ -73,7 +74,8 @@ export const Home: GlobalConfig = {
|
||||
name: 'items',
|
||||
type: 'array',
|
||||
fields: [
|
||||
{ name: 'id', type: 'text', required: true },
|
||||
// MITHOME-138: own field; as the row `id` it was the row's primary key.
|
||||
{ name: 'key', type: 'text', required: true, admin: { description: 'Rövid, egyedi azonosító (pl. hosting).' } },
|
||||
{ name: 'title', type: 'text', required: true, localized: true },
|
||||
{ name: 'description', type: 'textarea', required: true, localized: true },
|
||||
{ name: 'icon', type: 'text', required: true },
|
||||
|
||||
@@ -92,4 +92,10 @@ describe('content transfer (MITHOME-136)', () => {
|
||||
expect(upgradeDoc('legal-pages', upgradeDoc('legal-pages', doc))).toEqual(upgradeDoc('legal-pages', doc))
|
||||
expect(upgradeDoc('partners', doc)).toBe(doc)
|
||||
})
|
||||
it('should move the Home usps/items key out of the row id, keeping the row id', () => {
|
||||
const home = { about: { usps: [{ id: 'egyszeru', icon: '🎯' }] }, services: { items: [{ id: 'hosting' }] } }
|
||||
const upgraded = upgradeDoc('home', home) as { about: { usps: unknown[] }; services: { items: unknown[] } }
|
||||
expect(upgraded.about.usps).toEqual([{ id: 'egyszeru', key: 'egyszeru', icon: '🎯' }])
|
||||
expect(upgraded.services.items).toEqual([{ id: 'hosting', key: 'hosting' }])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -58,8 +58,20 @@ function splitFields(fields: readonly Field[], source: Data, locale: Locale, ids
|
||||
* - legal-pages: the section anchor was the array row `id`; it is now the
|
||||
* `anchor` field, and the row id must be unique across all pages (it is a
|
||||
* table-wide primary key in PostgreSQL), so it becomes `<slug>-<anchor>`.
|
||||
* - home (global): the usps/items row `id` was the editable key; it is now the
|
||||
* `key` field (MITHOME-138). The row id stays, so both locales hit the same row.
|
||||
*/
|
||||
const withKey = (rows: unknown) =>
|
||||
Array.isArray(rows)
|
||||
? rows.map((row) => (isObject(row) && typeof row.id === 'string' && !('key' in row) ? { ...row, key: row.id } : row))
|
||||
: rows
|
||||
|
||||
export function upgradeDoc(collection: string, doc: Data): Data {
|
||||
if (collection === 'home') {
|
||||
const about = isObject(doc.about) ? { ...doc.about, usps: withKey(doc.about.usps) } : doc.about
|
||||
const services = isObject(doc.services) ? { ...doc.services, items: withKey(doc.services.items) } : doc.services
|
||||
return { ...doc, about, services }
|
||||
}
|
||||
if (collection !== 'legal-pages' || !Array.isArray(doc.sections)) return doc
|
||||
return {
|
||||
...doc,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,26 @@
|
||||
/* MITHOME-138: generated by `payload migrate:create`, plus a hand-written backfill in up(). */
|
||||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||
|
||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
ALTER TABLE "home_about_usps" ADD COLUMN "key" varchar;
|
||||
ALTER TABLE "home_services_items" ADD COLUMN "key" varchar;
|
||||
ALTER TABLE "_home_v_version_about_usps" ADD COLUMN "key" varchar;
|
||||
ALTER TABLE "_home_v_version_services_items" ADD COLUMN "key" varchar;`)
|
||||
// MITHOME-138 (hand-written backfill): the editable key used to be the row
|
||||
// id itself; in the version tables the original row id is kept in `_uuid`.
|
||||
// The row ids stay, so the page renders the same rows.
|
||||
await db.execute(sql`
|
||||
UPDATE "home_about_usps" SET "key" = "id" WHERE "key" IS NULL;
|
||||
UPDATE "home_services_items" SET "key" = "id" WHERE "key" IS NULL;
|
||||
UPDATE "_home_v_version_about_usps" SET "key" = "_uuid" WHERE "key" IS NULL;
|
||||
UPDATE "_home_v_version_services_items" SET "key" = "_uuid" WHERE "key" IS NULL;`)
|
||||
}
|
||||
|
||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
ALTER TABLE "home_about_usps" DROP COLUMN "key";
|
||||
ALTER TABLE "home_services_items" DROP COLUMN "key";
|
||||
ALTER TABLE "_home_v_version_about_usps" DROP COLUMN "key";
|
||||
ALTER TABLE "_home_v_version_services_items" DROP COLUMN "key";`)
|
||||
}
|
||||
@@ -1,9 +1,15 @@
|
||||
import * as migration_20260929_202255_initial from './20260929_202255_initial';
|
||||
import * as migration_20260929_213538_home_row_keys from './20260929_213538_home_row_keys';
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
up: migration_20260929_202255_initial.up,
|
||||
down: migration_20260929_202255_initial.down,
|
||||
name: '20260929_202255_initial'
|
||||
name: '20260929_202255_initial',
|
||||
},
|
||||
{
|
||||
up: migration_20260929_213538_home_row_keys.up,
|
||||
down: migration_20260929_213538_home_row_keys.down,
|
||||
name: '20260929_213538_home_row_keys'
|
||||
},
|
||||
];
|
||||
|
||||
@@ -159,7 +159,8 @@ describe('Payload globals', () => {
|
||||
// MITHOME-113: `result`/`notes` are legal-validation metadata, not copy.
|
||||
// MITHOME-130: a product `name` is a brand, the same in every language.
|
||||
// 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'])
|
||||
// MITHOME-138: the Home usps/items `key` (formerly the row `id`) is shared too.
|
||||
const SHARED_TEXT_FIELDS = new Set(['icon', 'id', 'anchor', 'key', 'address', 'slug', 'result', 'notes', 'name'])
|
||||
|
||||
type Node = FieldLike & { localized?: boolean; fields?: Node[] }
|
||||
type Finding = { path: string; type?: string; localized: boolean }
|
||||
|
||||
Reference in New Issue
Block a user