I’ve my migrations at two different default location (database/migrations/tables/) and (database/migrations/foreign/) and i want to use the RefreshDatabase trait, however it uses the default migration location.
How can i specify or override at setUp or somewhere the "path" option for this migrations?
The only way that i found to do that is overriding "refreshInMemoryDatabase" and "refreshTestDatabase" methods but im thinking in a better way.
Can anyone help me in this trick!
2
Answers
Override the
refreshTestDatabase
method ofRefreshDatabase
trait by specifying--path=/app/database/migrations/tests
. It will be the best wayThe trait has two methods that are used to provide options to the migrate command:
migrateUsing()
when using a sqlite in-memory databasemigrateFreshUsing()
when not using a sqlite in-memory databaseAs an example, if using a sqlite in-memory database, you could do this:
Or, if you want to be able to call the original function, you can rename it when using the trait:
If you’re not using an in-memory database, you would need to override the
migrateFreshUsing()
method instead. In this case, the default logic is slightly more complicated, so it would probably be better to call it from the trait. That would look like: