From 127463f69ea05e32b6fbe439afdd9f085282749d Mon Sep 17 00:00:00 2001 From: Ollie Date: Sun, 20 Sep 2026 11:36:05 +0100 Subject: [PATCH] Add missing foreign key constraints to `wiki_id` columns Requires updating the column type to match the `wikis.id` column --- ...ign_key_constraints_to_wiki_id_columns.php | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 database/migrations/2026_09_14_000004_add_missing_foreign_key_constraints_to_wiki_id_columns.php 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 00000000..5d341622 --- /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(); + }); + } +};