I am working on a laravel 5.8 project. The app works well with mysql database on localhost. While deploying to heroku, i provisioned and set up heroku postgresql database. However, during migration to heroku, i keep getting this error message:
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
My users table comes before my locations table. users table has a foreign key column (location_id) related to locations table. My users migration file:
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');
});
and my locations migration file:
Schema::create('locations', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->timestamps();
});
My guess is that its reporting the error because locations "does not exist" at the point of running the users migration (which comes before locations). So how do i fix this?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire