Skip to content

Commit 9b79d9c

Browse files
committed
Delete service variables when the option is deleted.
1 parent 6269a08 commit 9b79d9c

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CascadeDeletionWhenServiceOptionIsDeleted extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up()
13+
{
14+
Schema::table('service_variables', function (Blueprint $table) {
15+
$table->dropForeign(['option_id']);
16+
17+
$table->foreign('option_id')->references('id')->on('service_options')->onDelete('CASCADE');
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*/
24+
public function down()
25+
{
26+
Schema::table('service_variables', function (Blueprint $table) {
27+
$table->dropForeign(['option_id']);
28+
29+
$table->foreign('option_id')->references('id')->on('service_options');
30+
});
31+
}
32+
}

0 commit comments

Comments
 (0)