id(); $table->string('name'); // Die Gruppe für Mandanten ohne Zuordnung; sie ist umbenennbar, aber nie löschbar. $table->boolean('is_fallback')->default(false); $table->timestamps(); }); $now = now(); $fallbackId = DB::table('parent_groups')->insertGetId([ 'name' => 'Ohne Zuordnung', 'is_fallback' => true, 'created_at' => $now, 'updated_at' => $now, ]); foreach (['BdP', 'DPV', 'DPSG', 'VCP'] as $name) { DB::table('parent_groups')->insert([ 'name' => $name, 'is_fallback' => false, 'created_at' => $now, 'updated_at' => $now, ]); } Schema::table('tenants', function (Blueprint $table) { $table->foreignId('parent_group_id')->nullable()->constrained('parent_groups')->restrictOnDelete(); }); DB::table('tenants')->update(['parent_group_id' => $fallbackId]); Schema::table('tenants', function (Blueprint $table) { $table->foreignId('parent_group_id')->nullable(false)->change(); }); Schema::table('events', function (Blueprint $table) { $table->string('participant_group_type')->default('local_group'); }); Schema::table('event_participants', function (Blueprint $table) { $table->foreignId('parent_group_id')->nullable()->constrained('parent_groups')->restrictOnDelete(); }); Schema::create('global_settings', function (Blueprint $table) { $table->string('key')->primary(); $table->text('value'); $table->timestamps(); }); foreach ([ 'local_group_label' => 'Stamm', 'local_group_label_plural' => 'Stämme', 'parent_group_label' => 'Bund', 'parent_group_label_plural' => 'Bünde', ] as $key => $value) { DB::table('global_settings')->insert([ 'key' => $key, 'value' => $value, 'created_at' => $now, 'updated_at' => $now, ]); } } public function down(): void { Schema::dropIfExists('global_settings'); Schema::table('event_participants', function (Blueprint $table) { $table->dropConstrainedForeignId('parent_group_id'); }); Schema::table('events', function (Blueprint $table) { $table->dropColumn('participant_group_type'); }); Schema::table('tenants', function (Blueprint $table) { $table->dropConstrainedForeignId('parent_group_id'); }); Schema::dropIfExists('parent_groups'); } };