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

使用外键创建表时的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条)

报告相同问题?