Eine Vorlage ist reines Layout (Titelseite mit allein stehendem Titel, Kopf- und Fußgrafik aus dem Medienbestand, Herausgeber und Standardvermerk) und wird dem Dokument zugeordnet. Untertitel, Ausgabe, Veröffentlichungsdatum und Copyright-Vermerk gehören zur Dokumentfassung (document_meta). Ohne Vorlage bleibt das PDF unverändert. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
56 lines
2.4 KiB
PHP
56 lines
2.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
/**
|
|
* PDF-Vorlagen für Dokumente (ADR-51, Nachtrag), rein additiv:
|
|
*
|
|
* - `pdf_templates`: Titelseite, Kopf- und Fußgrafik und Standardvermerke. Die Bilder verweisen auf freigegebene Bildfassungen
|
|
* des Medienbestands.
|
|
* - `compositions.pdf_template_id`: welche Vorlage ein Dokument verwendet (leer = bisheriges Layout).
|
|
* - `composition_versions.document_meta`: Untertitel, Ausgabe (Release), Veröffentlichungsdatum und Copyright-Vermerk einer
|
|
* Dokumentfassung. Sie sind Teil der Fassung und damit versioniert.
|
|
*
|
|
* Der Rückfall auf den vorherigen Programmstand setzt nur den Code zurück. Dieser kennt die Spalten und die Tabelle nicht;
|
|
* ohne Vorlage und ohne Angaben erzeugt er dasselbe PDF wie bisher.
|
|
*/
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('pdf_templates', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('name');
|
|
$table->string('kind')->default('dokument');
|
|
$table->boolean('show_cover')->default(true);
|
|
$table->foreignId('header_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete();
|
|
$table->foreignId('footer_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete();
|
|
$table->foreignId('cover_version_id')->nullable()->constrained('content_element_versions')->nullOnDelete();
|
|
$table->string('publisher')->nullable();
|
|
$table->text('copyright')->nullable();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::table('compositions', function (Blueprint $table) {
|
|
$table->foreignId('pdf_template_id')->nullable()->constrained('pdf_templates')->nullOnDelete();
|
|
});
|
|
|
|
Schema::table('composition_versions', function (Blueprint $table) {
|
|
$table->json('document_meta')->nullable();
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::table('composition_versions', function (Blueprint $table) {
|
|
$table->dropColumn('document_meta');
|
|
});
|
|
Schema::table('compositions', function (Blueprint $table) {
|
|
$table->dropConstrainedForeignId('pdf_template_id');
|
|
});
|
|
Schema::dropIfExists('pdf_templates');
|
|
}
|
|
};
|