diff --git a/database/migrations/2026_09_14_000004_add_missing_foreign_key_constraints_to_wiki_id_columns.php b/database/migrations/2026_09_14_000004_add_missing_foreign_key_constraints_to_wiki_id_columns.php new file mode 100644 index 000000000..5d3416224 --- /dev/null +++ b/database/migrations/2026_09_14_000004_add_missing_foreign_key_constraints_to_wiki_id_columns.php @@ -0,0 +1,91 @@ +foreignId('wiki_id')->change() + ->constrained() + ->restrictOnUpdate() + ->restrictOnDelete(); + }); + + Schema::table('queryservice_namespaces', function (Blueprint $table) { + $table->foreignId('wiki_id')->nullable()->change() + ->constrained() + ->restrictOnUpdate() + ->restrictOnDelete(); + }); + + Schema::table('wiki_dbs', function (Blueprint $table) { + $table->foreignId('wiki_id')->nullable()->change() + ->constrained() + ->restrictOnUpdate() + ->restrictOnDelete(); + }); + + Schema::table('wiki_domains', function (Blueprint $table) { + $table->foreignId('wiki_id')->nullable()->change() + ->constrained() + ->restrictOnUpdate() + ->restrictOnDelete(); + }); + + Schema::table('wiki_managers', function (Blueprint $table) { + $table->foreignId('wiki_id')->change() + ->constrained() + ->restrictOnUpdate() + ->restrictOnDelete(); + }); + + Schema::table('wiki_settings', function (Blueprint $table) { + $table->foreignId('wiki_id')->nullable()->change() + ->constrained() + ->restrictOnUpdate() + ->restrictOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void { + Schema::table('event_page_updates', function (Blueprint $table) { + $table->dropForeign(['wiki_id']); + $table->integer('wiki_id')->change(); + }); + + Schema::table('queryservice_namespaces', function (Blueprint $table) { + $table->dropForeign(['wiki_id']); + $table->unsignedInteger('wiki_id')->nullable()->change(); + }); + + Schema::table('wiki_dbs', function (Blueprint $table) { + $table->dropForeign(['wiki_id']); + $table->unsignedInteger('wiki_id')->nullable()->change(); + }); + + Schema::table('wiki_domains', function (Blueprint $table) { + $table->dropForeign(['wiki_id']); + $table->unsignedInteger('wiki_id')->nullable()->change(); + }); + + Schema::table('wiki_managers', function (Blueprint $table) { + $table->dropForeign(['wiki_id']); + $table->integer('wiki_id')->change(); + }); + + Schema::table('wiki_settings', function (Blueprint $table) { + $table->dropForeign(['wiki_id']); + $table->unsignedInteger('wiki_id')->nullable()->change(); + }); + } +};