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'); } };