From 21d9755e37cd482f91d9aa48dd0aba013753b1bf Mon Sep 17 00:00:00 2001 From: AdrianoDev Date: Mon, 20 Jul 2026 23:41:37 +0200 Subject: [PATCH] Migrazione: corregge il titolo Performance Class troncato a "Class" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nei DB esistenti (prod + dev) service.performance-class.title era rimasto "Class", mostrando "CLASS" come H1 della pagina /services/performance-class e nelle card di /services e home. Il seed è INSERT OR IGNORE e non lo aggiornava; una nuova installazione era invece corretta. Aggiunge una migrazione guardata dal vecchio valore (idempotente, non tocca le modifiche del pannello) che allinea a "Performance Class". Verificata su copia del DB di produzione: titolo corretto, 40 edit del pannello intatti. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/lib/db.ts | 6 ++++++ tests/content-db.test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/lib/db.ts b/src/lib/db.ts index 49a1779..c321d9d 100644 --- a/src/lib/db.ts +++ b/src/lib/db.ts @@ -177,6 +177,12 @@ export function createDb(path?: string): Database.Database { const updPromoTx = db.transaction(() => { for (const [tag, oldV, newV] of PROMO_FRECCE) upd02.run(newV, tag, oldV); }); updPromoTx(); + // Fix: il titolo del servizio Performance Class era rimasto troncato a "Class" nei DB esistenti + // (valore vecchio mai allineato dal seed INSERT OR IGNORE), mostrando "CLASS" come H1 della + // pagina /services/performance-class e nelle card di /services e home. Guardato dal vecchio + // valore → idempotente, non tocca eventuali modifiche del pannello. + db.prepare("UPDATE content_blocks SET value = 'Performance Class' WHERE tag = 'service.performance-class.title' AND value = 'Class'").run(); + // Modifiche 03: due ingressi dello stesso stabile → indirizzo esteso in footer e contatti. // Il tag global.contact.map-query è nuovo (inserito dal seed); qui si aggiorna solo l'indirizzo // già esistente, se non modificato dal pannello. Idempotente. diff --git a/tests/content-db.test.ts b/tests/content-db.test.ts index c2980f0..ce61e6b 100644 --- a/tests/content-db.test.ts +++ b/tests/content-db.test.ts @@ -113,6 +113,32 @@ describe('schema content_blocks e ruoli', () => { } }); + it('corregge il titolo Performance Class rimasto troncato a "Class"', () => { + const dir = mkdtempSync(join(tmpdir(), 'il-db-pc-')); + const path = join(dir, 'test.db'); + try { + // DB con il vecchio valore troncato. + const db1 = createDb(path); + db1.prepare("UPDATE content_blocks SET value = 'Class', updated_by = NULL WHERE tag = 'service.performance-class.title'").run(); + db1.close(); + + const db2 = createDb(path); + const val = (tag: string) => (db2.prepare('SELECT value FROM content_blocks WHERE tag = ?').get(tag) as { value: string }).value; + expect(val('service.performance-class.title')).toBe('Performance Class'); + db2.close(); + + // Non deve toccare un valore modificato dal pannello. + const db3 = createDb(path); + db3.prepare("UPDATE content_blocks SET value = 'Titolo mio', updated_by = 'admin' WHERE tag = 'service.performance-class.title'").run(); + db3.close(); + const db4 = createDb(path); + expect((db4.prepare("SELECT value FROM content_blocks WHERE tag = 'service.performance-class.title'").get() as { value: string }).value).toBe('Titolo mio'); + db4.close(); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); + it('migra un DB esistente senza colonna role', () => { // simula DB vecchio: createDb due volte sullo stesso path in-memory non è possibile, // quindi si verifica che la migrazione sia idempotente (doppia esecuzione non lancia)