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();
});
这是错误 .
Illuminate \ Database \ QueryException:SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误;查看与您的MariaDB服务器版本对应的手册,以便在第1行的')'附近使用正确的语法(SQL:alter table tasks add constraint tasks_company_id_foreign foreign key(company_id)references``())1 PDOException ::(“SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法中有错误;请检查与您的MariaDB服务器版本对应的手册,以便在第1行的“)'附近使用正确的语法”C:\ xampp \ htdocs \ blog \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connection.php:452 2 PDO :: prepare(“alter table tasks add constraint tasks_company_id_foreign foreign key(company_id)references”`()“)C:\ xampp \ htdocs中\博客\供应商\ laravel \框架的\ src \照亮\数据库\ Connection.php:452
我需要一些帮助 .