It's a frustrating experience if users have to remember to run each of their hanami db commands again with -e test after running them on their development database.
To improve this, update a number of commands to automatically re-run on the test database after completing their work on the development database:
db create
db drop
db migrate
db prepare
db structure load
The re-run on test will only take place if these commands operate with the development environment. Running the commands in other environments (e.g. production or test) will run on the database in those environments only.
To achieve this "re-run on test" behaviour, at the end of these db commands, we invoke another process to call the relevant hanami db command again, but with the HANAMI_ENV=test environment variable set. For this re-run, all given CLI flags are preserved, but -e and --env are of course stripped.
The reason we have to take this approach is because right now there's no straightforward way to re-boot the Hanami app in a different environment, or stand up the database subsystem itself in a different environment.
I'd like to for us to make one of these possible (certainly the latter feels reasonable) in the future, but to make the user experience as good as possible for 2.2, we're taking a pragmatic approach here.
It's a frustrating experience if users have to remember to run each of their
hanami db
commands again with-e test
after running them on their development database.To improve this, update a number of commands to automatically re-run on the test database after completing their work on the development database:
db create
db drop
db migrate
db prepare
db structure load
The re-run on test will only take place if these commands operate with the development environment. Running the commands in other environments (e.g. production or test) will run on the database in those environments only.
To achieve this "re-run on test" behaviour, at the end of these
db
commands, we invoke another process to call the relevanthanami db
command again, but with theHANAMI_ENV=test
environment variable set. For this re-run, all given CLI flags are preserved, but-e
and--env
are of course stripped.The reason we have to take this approach is because right now there's no straightforward way to re-boot the Hanami app in a different environment, or stand up the database subsystem itself in a different environment.
I'd like to for us to make one of these possible (certainly the latter feels reasonable) in the future, but to make the user experience as good as possible for 2.2, we're taking a pragmatic approach here.
Resolves #215