Issue
I had migrated a migration in Laravel which was like this:
$table->unsignedBigInteger('rel_seller_id')->nullable();
$table->foreign('rel_seller_id')->references('id')->on('seller');
Now I need to change the seller
table to sellers
table.
But don't know how to do this with Migration!
So if you know, let me know please...
Solution
Just create a new migration.
...
public function up()
{
Schema::table('table_name', function (Blueprint $table) {
$table->dropForeign(['rel_seller_id']);
$table->foreign('rel_seller_id')
->references('id')
->on('sellers');
});
}
...
It will drop old foreign key and create a new one.
Answered By - S N Sharma Answer Checked By - David Goodson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.