lately I’ve been trying to update some of my development processes and I came around one problem. I am trying to keep different Git branches in my local environment, especially for some experiments and updates, that can potentially break main version of my OctoberCMS website. I included in Git also vendor files and composer.lock to easily revert broken updates when needed.
The only thing, that remains to be solved is DB. My idea is that if I update OctoberCMS and some plugins, it also run some migrations in DB. But now if I switch back to main branch, there is still this updated database. I was wondering if I can somehow easily rollback it to version it has before. Basically every time I change branch.
I know I can drop it through
php artisan october:migrate --rollback and then build it again, but I will lose my data this way. Which is actually another of my requirements. I would like to keep them. At least those not directly affected with migration.
Another idea that I came up with is to create new DB for every branch. I would add it to my
.env file and set it up in config. This way it would automatically change when I am switching branches. And if merge something to main branch, I would only run
php artisan october:migrate.
This works for me so far, but my question is if this is good approach. Does anybody have some best practices or advices in this area?
Thank you in advance.