以下是我的迁移
users 表与 customer 表有关系
在用户中:
$table->integer('customer_id')->unsigned();
$table->foreign('customer_id')->references('id')->on('customers');
当我打电话时php artisan migrate:refresh --seed
,工匠给了我以下错误:
[Illuminate\Database\QueryException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL
: alter table `users` add constraint `users_customer_id_foreign` foreign ke
y (`customer_id`) references `customers` (`id`))
[PDOException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
因为客户表不存在......(很明显)
有没有办法解决这个问题?我知道更改文件的日期会解决这个问题,但应该有更好的方法