Laravel Artisan Migrate “Table Already Exists” or “Foreign Key” Error

在部署半年前用 Laravel 5.2 開發的專案時遇到不少問題,其中一個就是執行 php artisan migrate 之後卻遇到 Table Already Exists 的錯誤,但在這之前我從未建立過該 Table,後來深入研究發現該 Table 確實存在但 project_migrations Table 裡面卻沒有建立紀錄,於是我將 Table 手動刪除後在直接執行一次 php artisan migrate,果然,這次出現了真正的錯誤訊息:「General error: 1005 Can’t create table ‘dbname.#sql-fbc1_15e6’ (errno: 121) (SQL: alter table `karl_project` add constraint `project_user_id_foreign` foreign key (`user_id`) references `karl_user`
(`id`))」

閱讀全文 Laravel Artisan Migrate “Table Already Exists” or “Foreign Key” Error