Hi team,
All other tables having same data type, i just created reports and category_reports table, however i can't migrate them to db, i changed data type, but stil not working.
SQLSTATE[HY000]: General error: 1005 Can't create table `db`.`reports` (errno: 150 "Foreign key constraint is incorrectly formed") (Connection: mysql, SQL: alter table `reports` add constraint `reports_category_report_id_foreign` foreign key (`category_report_id`) references `category_reports` (`id`))
reports table
Schema::create('reports', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('user_id')->unsigned();
$table->unsignedBigInteger('category_report_id')->unsigned();
$table->timestamps();
$table->softDeletes();
$table->foreign('category_report_id')->references('id')->on('category_reports')-
>onCascade('delete');
$table->foreign('user_id')->references('id')->on('users')->onCascade('delete');
});
in category_repots table
Schema::create('category_reports', function (Blueprint $table) {
$table->bigIncrements('id');
$table->longText('title');
$table->timestamps();
});
in users table
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id')->unsigned();
$table->rememberToken();
$table->timestamps();
});
All other tables i have having $table->bigIncrements('id'); as id
and then $table->unsignedBigInteger('x_id')->unsigned(); as foreign key
I appreciate your support !