Answers for "adding new foreign key in migration laravel"

PHP
5

foreign key laravel migration

$table->foreign('column_name')->references('id')->on('table_name')->onDelete('cascade');
Posted by: Guest on February-05-2021
1

Laravel adding Foreign Key Constraints

$table->foreignId('user_id')
      ->constrained("users") <- // You don't need to specify table if it matched laravel naming conventions.
      ->onUpdate('cascade')
      ->onDelete('cascade');
Posted by: Guest on June-16-2021

Code answers related to "adding new foreign key in migration laravel"

Browse Popular Code Answers by Language