From 1ed1e97088dd7e935aac837ae628d8e8a5b9e24b Mon Sep 17 00:00:00 2001 From: PseudoResonance Date: Thu, 9 Jan 2025 14:47:32 +0000 Subject: [PATCH] Cascade delete from database_host_node when the database host is deleted --- ...abase_host_node_foreign_delete_cascade.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 database/migrations/2025_01_09_143607_database_host_node_foreign_delete_cascade.php diff --git a/database/migrations/2025_01_09_143607_database_host_node_foreign_delete_cascade.php b/database/migrations/2025_01_09_143607_database_host_node_foreign_delete_cascade.php new file mode 100644 index 0000000000..f0293fd37a --- /dev/null +++ b/database/migrations/2025_01_09_143607_database_host_node_foreign_delete_cascade.php @@ -0,0 +1,30 @@ +dropForeign(['database_host_id']); + $table->foreign('database_host_id')->references('id')->on('database_hosts')->cascadeOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('database_host_node', function (Blueprint $table) { + $table->dropForeign(['database_host_id']); + $table->foreign('database_host_id')->references('id')->on('database_hosts')->noActionOnDelete(); + }); + } +};