Laravel 5 Laravel 5.8错误SQLSTATE[HY000]:一般错误:1005 uuid
我正在使用Laravel 5.8和软件包,因为我需要使用UUID4,这是我的迁移文件:Laravel 5 Laravel 5.8错误SQLSTATE[HY000]:一般错误:1005 uuid,laravel-5,eloquent,laravel-5.8,Laravel 5,Eloquent,Laravel 5.8,我正在使用Laravel 5.8和软件包,因为我需要使用UUID4,这是我的迁移文件: public function up() { Schema::create('images', function (Blueprint $table) { $table->bigIncrements('id'); // $table->timestamps(); $table->string('
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->bigIncrements('id');
// $table->timestamps();
$table->string('path');
$table->uuid('visit_id');
$table->foreign('visit_id')->references('id')->on('visits');
});
}
我得到以下错误:
SQLSTATE[HY000]:一般错误:1005无法创建表documents
_药房
图像
(错误号:150“外键约束格式不正确”)(SQL:alter table图像
添加约束图像\u访问\u id\u外键
外键(访问\u id
)引用访问
(id
)
如何解决此问题?更新
访问
和图像
的模式
,如下所示。
然后运行php artisan migrate
cmd
访问
表架构
public function up()
{
Schema::create('visits', function (Blueprint $table) {
$table->uuid('id')->primary();
// your column will be here
......
......
$table->timestamps();
});
}
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('path');
$table->uuid('visit_id');
$table->foreign('visit_id')->references('id')->on('visits');
});
}
图像
表架构
public function up()
{
Schema::create('visits', function (Blueprint $table) {
$table->uuid('id')->primary();
// your column will be here
......
......
$table->timestamps();
});
}
public function up()
{
Schema::create('images', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('path');
$table->uuid('visit_id');
$table->foreign('visit_id')->references('id')->on('visits');
});
}