Skip to content

Commit

Permalink
Fix deleting database host when it has assigned nodes (#899)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Update 2025_01_09_143607_database_host_node_foreign_delete_cascade.php

Fix brace position

---------

Co-authored-by: MartinOscar <[email protected]>
  • Loading branch information
PseudoResonance and RMartinOscar authored Jan 9, 2025
1 parent 9cfd870 commit d088e79
Showing 1 changed file with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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 {}
};

0 comments on commit d088e79

Please sign in to comment.