【问题标题】:A foreign key constraint fails on laravel 5 frameworklaravel 5 框架上的外键约束失败
【发布时间】:2018-01-01 10:41:26
【问题描述】:

我正在开发 laravel 5 框架。

完整性约束违规:1452 无法添加或更新子行:外键约束失败(database_name.students,CONSTRAINT students_ibfk_1 FOREIGN KEY (stu_id) REFERENCES admission_details (ad_id) )

【问题讨论】:

  • 你能详细说明一下吗?
  • 如果使用,请显示相关代码、迁移和关系。
  • stu_id 在 admission_details 中没有匹配的 ad_id。

标签: mysql laravel


【解决方案1】:

在 phpmyadmin 中运行此查询

ADD CONSTRAINT `students_ibfk_1` FOREIGN KEY (`type_id`) REFERENCES `admission_details`(`ad_id`) ON DELETE RESTRICT ON UPDATE NO ACTION;

希望对你有帮助

【讨论】:

    猜你喜欢
    • 2016-01-20
    • 2016-08-17
    • 1970-01-01
    • 2019-05-23
    • 2013-05-29
    • 1970-01-01
    • 1970-01-01
    • 2013-03-04
    • 2011-11-03
    相关资源
    最近更新 更多