I can't create a foreign table key:
$table->increments('rt_id');
$table->integer('issued_id')->unsigned();
$table->foreign('issued_id')->references('issue_id')->on('book_issues');
$table->integer('book_id')->unsigned();
$table->foreign('book_id')->references('id')->on('book_details');
I also tried this:
$table->bigIncrements('rt_id');
$table->unsignedBigInteger('issued_id');
$table->foreign('issued_id')->references('issue_id')->on('book_issues');
$table->unsignedBigInteger('book_id');
$table->foreign('book_id')->references('id')->on('book_details');
I just rechecked all the fields and the datatype, i observed that i used increments for primary key and in foreign key i had taken integer('book_id')->unsigned() And while migrating, i already had the primary table migrated so, i used php artisan migrate:fresh command then this time, it is migrating the foreign table time so, i'm getting the error. before my foreign key table is been placed first and then the primary key table is placed at last. So, i changed my model name and replaced according to key constraints as primary table should be stored first in migration folder even sometimes while migrating it doesn't migrates in sequences in ur folder. So, i used php artisan migrate:fresh This command is migrating all tables in sequences.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments