I am using Laravel 7 and PHP 7.4.
I'm working on databases and suddenly stuck over issue when I'm trying to generate a foreign key for user in another table. It should be straight away process and I'm following the doc, still getting error.
General error: 1005 Can't create table
carchain_qrcode.sellers(errno: 150 "Foreign key constraint is incorrectly formed
User Table
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigInteger('id');
$table->string('name')->unique();
$table->string('email')->unique();
});
}
Sellers Table
public function up()
{
Schema::create('sellers', function (Blueprint $table) {
$table->bigInteger('id');
$table->unsignedBigInteger('user_id');
$table->string('seller_name');
$table->string('seller_email');
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
});
Where have I gone wrong?