I would like to use Travis to run database schema migration on the server (staging, production) whenever needed as part of deployment. I have actually a few staging environments on AWS. My application is written in PHP and I have already installed lib to DB migration (Phinx).
Basically, I use Travis to run unit tests. When the tests are successful then the next step which I would like to do is deploy code to server e.g. staging or production. It depends if I merged my branch into test or master etc. However, before I pushed the code to the server, I would need to tun DB migration first.
- Run unit tests.
- Run DB migration (so new tables will exist on the DB before I deploy the code on the server).
- Deploy code.
- Happy days
I don’t want to run this task separately from my machine as it’s possible to run into a race condition with an automatically run deployment. I don’t want clients to see 500 HTTP code on my web app.
Any idea how can I do it? Should I create e.g. bash script on the servers and then just made Travis do fire that script e.g. by ssh? Or there are any other ways to do it?