Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/112.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 5 Laravel 5.8错误SQLSTATE[HY000]:一般错误:1005 uuid_Laravel 5_Eloquent_Laravel 5.8 - Fatal编程技术网

Laravel 5 Laravel 5.8错误SQLSTATE[HY000]:一般错误:1005 uuid

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('

我正在使用Laravel 5.8和软件包,因为我需要使用UUID4,这是我的迁移文件:

 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');

    });
}