sol如何解决此数据库迁移问题?

时间:2019-02-09 19:20:13

标签: database laravel migration

我在Laravel数据库迁移方面遇到麻烦。我已经在数据库迁移文件中输入了外键约束,但是当我尝试迁移文件时,它会显示此错误消息。

  

Illuminate \ Database \ QueryException:SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法有一个错误;请参见语法。请检查与您的MariaDB服务器版本相对应的手册,以在第1行(SQL:更改表education_qualifications添加约束education_qualifications_teacher_id_foreign外键({ {1}})引用teacher_id()有关更新级联上的删除级联),位于E:\ XAMPP \ htdocs \ ViduresaApp \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connection.php:664

teachers

异常跟踪:

  

1 PDOException::(“” SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法有错误;请查阅与您的MariaDB服务器版本相对应的手册,以找到在')附近使用正确的语法。在第1行的更新级联上删除级联”)         E:\ XAMPP \ htdocs \ ViduresaApp \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connection.php:452

     

2 PDO :: prepare(“更改表 660| // If an exception occurs when attempting to run a query, we'll format the error 661| // message to include the bindings with SQL, which will make this exception a 662| // lot more helpful to the developer instead of just the database's errors. 663| catch (Exception $e) { > 664| throw new QueryException( 665| $query, $this->prepareBindings($bindings), $e 666| ); 667| } 668| 添加约束education_qualifications外键(education_qualifications_teacher_id_foreign)引用teacher_id()在更新级联上删除级联”)         E:\ XAMPP \ htdocs \ ViduresaApp \ vendor \ laravel \ framework \ src \ Illuminate \ Database \ Connection.php:452

teachers

1 个答案:

答案 0 :(得分:0)

您可以在同一行上同时使用onupdate和ondelete

例如:

$table->foreign(’author’)->references(’id’)->on(’users’)->onUpdate(’cascade’);