Migration 20260912000500 legt eine Tabelle menu an: ein Menü je Platz (header, footer) und Sprache, Elementbaum als JSON, Version für dieselbe Konflikterkennung wie bei Seiten. Ein Eintrag verweist auf eine Seite, auf ein Sprungziel innerhalb einer Seite oder auf eine Adresse (HTTPS, lokaler Pfad, mailto:, tel:). Seitenverweise speichern die Seiten-ID, nie den Pfad - ein Eintrag folgt damit einer umbenannten Seite. Beim Rendern fallen Einträge zu gelöschten oder unveröffentlichten Seiten heraus, ohne den gespeicherten Baum zu ändern und ohne die übrigen Einträge zu verlieren. Die Verwaltung nutzt eine nummerierte Zeilenliste statt Drag-and-drop und funktioniert damit vollständig ohne JavaScript; Untermenüs in der Ausgabe über details/summary. tests/bootstrap.php verwirft var/cache/test je Lauf. Ohne Debug prüft Symfony weder den kompilierten Container noch die Vorlagen auf Aktualität, was zweimal ein falsches Testergebnis erzeugt hat. Geprüft: 79 PHP-Tests / 285 Assertions unter PHP 8.2.12 und 8.4.22, 11 JavaScript-Modelltests, Lint/Format/Container, Migration zuerst gegen eine Datenbankkopie, wiederholtes Seeding. Keine Browser- oder Lighthouse-Läufe. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260912000500 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Named menus per slot, stored as a validated item tree.';
|
|
}
|
|
|
|
public function isTransactional(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$menu = $schema->createTable('menu');
|
|
$menu->addColumn('id', 'string', ['length' => 64]);
|
|
$menu->addColumn('website_id', 'string', ['length' => 64]);
|
|
$menu->addColumn('locale', 'string', ['length' => 12]);
|
|
// One menu per slot and locale; the slot is what a template asks for.
|
|
$menu->addColumn('slot', 'string', ['length' => 32]);
|
|
$menu->addColumn('name', 'string', ['length' => 120]);
|
|
$menu->addColumn('items', 'json');
|
|
// Optimistic locking, same contract as pages: a stale form must not overwrite newer items.
|
|
$menu->addColumn('version', 'integer', ['default' => 0]);
|
|
$menu->setPrimaryKey(['id']);
|
|
$menu->addUniqueIndex(['website_id', 'locale', 'slot'], 'uniq_menu_slot');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->throwIrreversibleMigrationException('Contains the site navigation. Restore a verified database backup with matching code.');
|
|
}
|
|
}
|