Had an issue this week when started to try and use phpunit for testing more. It seems to rebuild the db each time running all the migrations, when testing sqlite option.
This was an issue as I had swapped to a feature branch but not deleted my db as there was data in it I wanted for views. All was ok for the app. But when the migrations re ran they now had one listed in the DB but it was on another branch. So I had to copy it over.
Any thoughts on DB and git branches. Should you work with a new db for each branch you use? or maybe some other way, as I would not normally want to do that if I could skip it. Also as the migrations list seems to be only stored in the db, would it work to keep switching?
I would gitignore the sqlite DB and play with the .env files to point to the right file instead (if you need one specific for your branch), less headache.
Hi @mdecooman
The issue or point to be aware of is not the sqlite db as I see it, it is the list of migrations is stored in the DB.
So if you move branch to build a new feature, add some migrations (they will be added to the db table and changes)
Then if you switch branch before you need to fold that one back in. The db will contain the migrations in the list but the new branch will not, as the php files for the migration are in a different branch.
So you either need to rebuild the db each time you have a new branch or you need to manage the migrations differently.
My previous answer was a bit fast (and dumb I must confess ;) Here is a better attempt to answer your questions:
Should you work with a new db for each branch you use?
Personally I wouldn't unless the branch is disruptive enough. I make backups of the DB to keep my sanity (<name-of-the-branch>-datetime.sql).
or maybe some other way
You shouldn't have to 'rebuild' the db each time you have a new feature-branch. Rolling back the migrations done in the current branch before switching is one of the reasons having the migration files. About the data you can have seeders and some relevant SQL exports to keep data for your specific views should a migration:refresh or rebuild be triggered.