Fix deleting database host when it has assigned nodes (#899)

* Cascade delete from database_host_node when the database host is deleted

* Update database/migrations/2025_01_09_143607_database_host_node_foreign_delete_cascade.php

Remove migration rollback

Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com>

* Update 2025_01_09_143607_database_host_node_foreign_delete_cascade.php

Fix brace position

---------

Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
Josh 2025-01-09 11:21:44 -08:00 committed by GitHub
parent 9cfd87090f
commit d088e79e5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('database_host_node', function (Blueprint $table) {
$table->dropForeign(['database_host_id']);
$table->foreign('database_host_id')->references('id')->on('database_hosts')->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void {}
};