I am setting up Vagrant with multiple developers using ScotchBox (v2.5) in our workplace, I have got the initial vagrantfile working ok however I’m unsure of how best to handle Database migrations.
We essentially have two sites :-
- Frontend site (AngularJS 1.x)
- Backend site (Zend 1.x – PHP/MySQL)
Colleagues will occasionally edit the database (add/remove columns etc..) I have used migration tools with Yii & Laravel in the past, but those tools aren’t available as I’m using the old Zend Framework.
In a nutshell, I am looking for a solution that will allow all of my colleagues to be able to do the following:
- Use some form of database migration tool (supporting MySQL) to add/edit/remove tables and columns
- Push these ‘migrations’ into a git repo that we can all access
- Each developer can then run a ‘git pull’ on that repo and retrieve any migrations found
- They run a single command via the SSH terminal and this updates the DB structure within the Vagrant box
Can anyone confirm if this is possible within a Virtual Machine, and if so what is the best way to go about this
Yes, you can. When provisioning your box simply include the ‘deployment’ of your software on the vagrant box as part of that provisioning. With that setup when you pull changes from source control you can re-provision the box and it will run the new scripts that have been pulled from source control. I consider setting up your project part of the provisioning because ‘vagrant up’ in a new checkout from source should be the only step needed to drop a working version of the application on a developer’s machine.
I’m doing something similar in my own projects which relies on the Doctrine Migrations Bundle for Symfony to get this done. Obviously YMMV for your specific case (esp. with ScotchBox this might not be as easy as ‘just provision your application’) but it can be done.