Paket 2: konfigurierbare Inhaltsart an Identitaet
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7820bececb
commit
1a2b1298b5
8 files changed
+233
-1
No files matched your search
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('editorial_content_kinds', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('slug')->unique();
|
||||
$table->string('label');
|
||||
$table->unsignedInteger('sort_order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
$now = now();
|
||||
foreach ([
|
||||
['slug' => 'programm', 'label' => 'Programm', 'sort_order' => 10],
|
||||
['slug' => 'modul', 'label' => 'Modul', 'sort_order' => 20],
|
||||
['slug' => 'merkblatt', 'label' => 'Merkblatt', 'sort_order' => 30],
|
||||
['slug' => 'traineranleitung', 'label' => 'Traineranleitung', 'sort_order' => 40],
|
||||
] as $row) {
|
||||
DB::table('editorial_content_kinds')->insert([
|
||||
...$row,
|
||||
'created_at' => $now,
|
||||
'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
|
||||
Schema::table('compositions', function (Blueprint $table) {
|
||||
$table->foreignId('editorial_content_kind_id')
|
||||
->nullable()
|
||||
->after('kind')
|
||||
->constrained('editorial_content_kinds')
|
||||
->nullOnDelete();
|
||||
});
|
||||
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->foreignId('editorial_content_kind_id')
|
||||
->nullable()
|
||||
->after('output_class')
|
||||
->constrained('editorial_content_kinds')
|
||||
->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('content_elements', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('editorial_content_kind_id');
|
||||
});
|
||||
|
||||
Schema::table('compositions', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('editorial_content_kind_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('editorial_content_kinds');
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user