Skip to content

Commit 37d7e66

Browse files
author
ahmadhuss
committed
refactor: Updated migration foreign key
1 parent e5ace44 commit 37d7e66

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

database/migrations/2021_05_27_103257_create_products_table.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ public function up()
1818

1919
// Foreign key
2020
$table->unsignedBigInteger('category_id');
21-
$table->foreign('category_id')->references('id')->on('categories');
21+
$table->foreign('category_id')->references('id')->on('categories')
22+
->onUpdate('cascade')
23+
->onDelete('cascade');
2224

2325
$table->string('name');
2426
$table->decimal('price');

0 commit comments

Comments
 (0)