Symfony 7.4 / Twig / Doctrine DBAL auf herkömmlichem PHP-Webhosting. Versionierte Blockdokumente (v1-v3) mit unveränderlichen Revisionen, getrennten Entwürfen/Veröffentlichungen und optimistischer Konflikterkennung. Visueller Editor mit Strukturbaum, Live-Vorschau, responsiven Gerätewerten, Abschnittsvorlagen, Bildmediathek, Galerien und Effekten. Öffentliche Ausgabe ohne Editor-JavaScript. Geprüft: 41 PHP-Tests / 155 Assertions, 10 JavaScript-Modelltests. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
55 lines
2.2 KiB
PHP
55 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260912000100 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Website, localized pages and immutable document revisions (schema v1).';
|
|
}
|
|
|
|
public function isTransactional(): bool
|
|
{
|
|
return false; // MySQL DDL commits implicitly. Backup before production migrations.
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$site = $schema->createTable('website');
|
|
$site->addColumn('id', 'string', ['length' => 64]);
|
|
$site->addColumn('name', 'string', ['length' => 200]);
|
|
$site->addColumn('default_locale', 'string', ['length' => 12]);
|
|
$site->addColumn('theme', 'json');
|
|
$site->setPrimaryKey(['id']);
|
|
|
|
$page = $schema->createTable('page');
|
|
$page->addColumn('id', 'string', ['length' => 64]);
|
|
$page->addColumn('website_id', 'string', ['length' => 64]);
|
|
$page->addColumn('slug', 'string', ['length' => 160]);
|
|
$page->addColumn('locale', 'string', ['length' => 12]);
|
|
$page->addColumn('draft_revision_id', 'string', ['length' => 64, 'notnull' => false]);
|
|
$page->addColumn('published_revision_id', 'string', ['length' => 64, 'notnull' => false]);
|
|
$page->addColumn('version', 'integer', ['default' => 0]);
|
|
$page->setPrimaryKey(['id']);
|
|
$page->addUniqueIndex(['website_id', 'locale', 'slug']);
|
|
$page->addForeignKeyConstraint('website', ['website_id'], ['id']);
|
|
|
|
$revision = $schema->createTable('revision');
|
|
$revision->addColumn('id', 'string', ['length' => 64]);
|
|
$revision->addColumn('page_id', 'string', ['length' => 64]);
|
|
$revision->addColumn('document', 'json');
|
|
$revision->addColumn('created_at', 'datetime_immutable');
|
|
$revision->setPrimaryKey(['id']);
|
|
$revision->addForeignKeyConstraint('page', ['page_id'], ['id']);
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->throwIrreversibleMigrationException('Contains customer content. Restore a verified database backup and matching code.');
|
|
}
|
|
}
|