douxia6163 2018-01-04 10:10
浏览 52
已采纳

使用外键创建表时的Laravel迁移错误

I am using laravel's artisan command to create a database table with a foreign key. I'm getting the following error when I run the php artisan migrate command:

SQLSTATE[23000]: Integrity constraint violation: 1022 Can't write; duplicate key in table '#sql-73_ca' (SQL: alter table table_1 add constraint table_1_table_1_sid_foreign foreign key
(table_1_sid) references table_2 (id))

Also, I don't have a table '#sql-73_ca'

  • 写回答

2条回答 默认 最新

  • dsa5211314 2018-01-04 11:28
    关注

    if you using phpmyadmin you should copy a section of error notification to the query sql in phpmyadmin:

    " alter table table_1 add constraint table_1_table_1_sid_foreign 
    foreign key (table_1_sid) references table_2 (id)"
    

    It will display more information for error

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统
  • ¥15 快手联盟怎么快速的跑出建立模型