Framework: RefreshDatabase trait won't refresh multiple connections

Created on 4 Oct 2017  路  3Comments  路  Source: laravel/framework

  • Laravel Version: 5.5 +
  • PHP Version: PHP 7.0.22-0ubuntu0.17.04.1 (cli) (built: Aug 8 2017 22:03:30)
  • Database Driver & Version: PostgreSQL 9.6.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16), 64-bit

Description:

I know that the migrate:fresh artisan command will refresh only the default connection. But as the current project I'm working on uses PostgreSQL with several schemas I have to refresh several connections in order to intrinsically refresh the database, therefore the RefreshDatabase trait will only refresh the default connection and the migrations try to create tables in the other connections (where the tables haven't been dropped), thus generating errors.
I've been searching for an answer but I couldn't find anything. This seems like an issue to me, though I might be wrong and a workaround might exist.

Steps To Reproduce:

  1. Create 2 migrations that each use a different connection.
  2. Create a test that uses RefreshDatabase trait and run it.

Most helpful comment

Instead of using RefreshDatabase, just call $this->artisan('migrate:refresh') on the setUp() method.

All 3 comments

Well we're open to pull requests, also you can open a discussion on https://github.com/laravel/internals to see what people think about that.

Closing since it's not actually a bug.

+1 any update on how to accomplish this?

Instead of using RefreshDatabase, just call $this->artisan('migrate:refresh') on the setUp() method.

Was this page helpful?
0 / 5 - 0 ratings