public function up()
{
Schema::create('jobs', function (Blueprint $table) {
$table->id()->autoIncrement();
$table->unsignedBigInteger('position_id');
$table->unsignedBigInteger('taskmaster');
$table->Integer('task_id');
$table->string('title',150);
$table->string('description')->nullable();
$table->timestamp('finished_at')->nullable();
$table->timestamps();
$table->foreign('position_id')->references('id')->on('positions')->onDelete('cascade');
$table->foreign('taskmaster')->references('id')->on('users')->onDelete('cascade');
$table->foreign('task_id')->references('id')->on('firmas')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('jobs');
}
I have a problem on laravel. When I add the first two foreign keys, it does not give a problem, but when I add the foreign key of the 'company' table at the bottom, it gives an error. The error is as follows:
General error: 1005 Can't create table `advertisement`.`jobs` (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table `jobs` add constraint `jobs_task_id_foreign` foreign key (`task_id`) references `firmas` (`id`) on delete cascade)