Quellübung mit stabiler Kennung und Inhaltswert, genau ein Stand je Prüfsumme, bewusste Übernahme als neue lokale Fassung, lokale Ergänzungen bleiben erhalten, Ausblenden an der Quelle setzt nur die Verfügbarkeit. Seite Übernahme (Shinkan), Feldzuordnung, ADR-49 (inklusive Abweichung bei der Mediensperre), Abnahmestand und Rückfallverfahren. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
93 lines
3.7 KiB
PHP
93 lines
3.7 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
/**
|
|
* Übernahme aus einer Quelle (Shinkan), rein additiv. Die Quelle ist an ihre stabile Kennung gebunden; jeder Inhaltsstand
|
|
* (Prüfsumme) wird genau einmal festgehalten. Eine lokale Fassung entsteht erst mit der bewussten Übernahme.
|
|
*/
|
|
return new class extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
Schema::create('exercise_sources', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('source_system')->default('shinkan');
|
|
$table->string('source_id');
|
|
$table->foreignId('composition_id')->nullable()->constrained()->nullOnDelete();
|
|
$table->string('title')->nullable();
|
|
// bereitgestellt | nicht_mehr_bereitgestellt: nur die Verfügbarkeit an der Quelle, kein Rechtsvorgang.
|
|
$table->string('availability')->default('bereitgestellt');
|
|
$table->string('last_hash')->nullable();
|
|
$table->timestamp('last_seen_at')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->unique(['source_system', 'source_id']);
|
|
});
|
|
|
|
Schema::create('exercise_source_snapshots', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('exercise_source_id')->constrained()->cascadeOnDelete();
|
|
$table->string('content_hash');
|
|
$table->json('payload');
|
|
$table->unsignedBigInteger('adopted_version_id')->nullable();
|
|
$table->timestamp('fetched_at');
|
|
$table->timestamps();
|
|
|
|
$table->unique(['exercise_source_id', 'content_hash']);
|
|
});
|
|
|
|
Schema::create('exercise_import_runs', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->string('source_system')->default('shinkan');
|
|
$table->string('status');
|
|
$table->string('cursor')->nullable();
|
|
$table->unsignedInteger('added')->default(0);
|
|
$table->unsignedInteger('updated')->default(0);
|
|
$table->unsignedInteger('removed')->default(0);
|
|
$table->text('error')->nullable();
|
|
$table->timestamp('started_at');
|
|
$table->timestamp('finished_at')->nullable();
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::table('content_elements', function (Blueprint $table) {
|
|
$table->string('source_ref')->nullable()->index();
|
|
});
|
|
|
|
Schema::table('composition_versions', function (Blueprint $table) {
|
|
$table->unsignedBigInteger('source_snapshot_id')->nullable();
|
|
});
|
|
|
|
Schema::table('composition_members', function (Blueprint $table) {
|
|
// quelle | lokal: Was stammt aus der Quelle, was hat die Redaktion lokal ergänzt?
|
|
$table->string('origin')->default('lokal');
|
|
});
|
|
|
|
Schema::table('composition_version_variants', function (Blueprint $table) {
|
|
$table->string('origin')->default('lokal');
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::table('composition_version_variants', function (Blueprint $table) {
|
|
$table->dropColumn('origin');
|
|
});
|
|
Schema::table('composition_members', function (Blueprint $table) {
|
|
$table->dropColumn('origin');
|
|
});
|
|
Schema::table('composition_versions', function (Blueprint $table) {
|
|
$table->dropColumn('source_snapshot_id');
|
|
});
|
|
Schema::table('content_elements', function (Blueprint $table) {
|
|
$table->dropColumn('source_ref');
|
|
});
|
|
Schema::dropIfExists('exercise_import_runs');
|
|
Schema::dropIfExists('exercise_source_snapshots');
|
|
Schema::dropIfExists('exercise_sources');
|
|
}
|
|
};
|