当尝试在Laravel中添加外键约束时,我收到以下错误.
[PDOException] SQLSTATE[HY000]: General error: 1005 Can't create table 'ts.#sql-5769_62' (errno: 150)
我有2张桌子,users
和teams
.关系是团队可以有很多用户,用户有一个团队.
用户
$table->increments('id'); $table->integer('team_id'); $table->string('name', 255); $table->string('username', 32)->unique(); $table->string('email', 320); $table->string('password', 64); $table->foreign('team_id')->references('id')->on('teams'); $table->timestamps();
小组
$table->increments('id'); $table->string('team_name', 255); $table->string('website', 255); $table->timestamps();
我究竟做错了什么?这也是我第一次使用迁移,所以欢迎任何指出愚蠢错误的帮助.