Laravel 5.6 Migration error SQLSTATE[42000]
Clash Royale CLAN TAG#URR8PPP
Laravel 5.6 Migration error SQLSTATE[42000]
I am working on a project, i ran a migration and stumbled on an error,
here is my code.
Schema::create('tasks', function (Blueprint $table)
$table->increments('id');
$table->string('name');
$table->integer('project_id')->unsigned();
$table->integer('user_id')->unsigned();
$table->integer('days')->unsigned()->nullable();
$table->integer('hours')->unsigned()->nullable();
$table->foreign('company_id')->unsigned()->nullable();
$table->foreign('user_id')->references('id')->on('users');
$table->foreign('project_id')->references('id')->on('projects');
$table->foreign('company_id')->references('id')->on('companies');
$table->timestamps();
);
Here is the error.
IlluminateDatabaseQueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 (SQL: alter table tasks
add constraint tasks_company_id_foreign
foreign key (company_id
) references `` ())
tasks
tasks_company_id_foreign
company_id
1 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1")
C:xampphtdocsblogvendorlaravelframeworksrcIlluminateDatabaseConnection.php:452
2 PDO::prepare("alter table tasks
add constraint tasks_company_id_foreign
foreign key (company_id
) references `` ()")
C:xampphtdocsblogvendorlaravelframeworksrcIlluminateDatabaseConnection.php:452
tasks
tasks_company_id_foreign
company_id
I need some help.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.