SQLSTATE [42P01]:未定义表:7错误:在部署到heroku的迁移过程中,该关系不存在错误

我正在研究laravel 5.8项目。该应用程序可与localhost上的mysql数据库配合使用。 在部署到heroku时,我设置并设置了heroku postgresql数据库。但是,在迁移到heroku期间,我不断收到此错误消息:

Migrating: 2014_10_12_000000_create_users_table

In Connection.php line 664:

  SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "locations" does not e
  xist (SQL: alter table "users" add constraint "users_location_id_foreign" f
  oreign key ("location_id") references "locations" ("id"))


In Connection.php line 458:

  SQLSTATE[42P01]: Undefined table: 7 ERROR:  relation "locations" does not e
  xist

我的用户表位于我的位置表之前。 users表具有与locations表相关的外键列(location_id)。我的用户迁移文件:

Schema::create('users',function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('name');
        $table->string('email')->unique();
        $table->string('phone');
        $table->timestamp('email_verified_at')->nullable();
        $table->string('password');
        $table->rememberToken();
        $table->timestamps();

        $table->foreign('location_id')->references('id')->on('locations');
    });

和我的位置迁移文件:

Schema::create('locations',function (Blueprint $table) {
    $table->bigIncrements('id');
    $table->string('name');
    $table->timestamps();
});

我的猜测是它报告该错误是因为在运行用户迁移时位置“不存在”(位置之前)。 那我该如何解决呢?

S13171830970 回答:SQLSTATE [42P01]:未定义表:7错误:在部署到heroku的迁移过程中,该关系不存在错误

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3044988.html

大家都在问