-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cascade delete from database_host_node when the database host is deleted
- Loading branch information
1 parent
9cfd870
commit 1ed1e97
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
database/migrations/2025_01_09_143607_database_host_node_foreign_delete_cascade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?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 | ||
{ | ||
Schema::table('database_host_node', function (Blueprint $table) { | ||
$table->dropForeign(['database_host_id']); | ||
$table->foreign('database_host_id')->references('id')->on('database_hosts')->noActionOnDelete(); | ||
}); | ||
} | ||
}; |