Answers for "create migration to add foreign key"

PHP
1

create foreign key laravel migration

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
Posted by: Guest on February-15-2021
0

Add foreign key to existing table

ALTER TABLE message ADD FOREIGN KEY (sender) REFERENCES users;
Posted by: Guest on March-02-2022

Code answers related to "create migration to add foreign key"

Browse Popular Code Answers by Language