时尝试使用laravel迁移为什么发生这个错误
像这样的例子,当使外键:
用户表
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->TinyInteger('color_id')->unsigned();
$table->foreign('color_id')->references('id')->on('colors');
$table->timestamps();
});
}
色表
public function up()
{
Schema::create('flights', function (Blueprint $table) {
$table->increments('id');
$table->string('color');
$table->timestamps();
});
}
有时属性不起作用
[PDOException]
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint