I am developing a PHP based application and using Capistrano to deploy it to my webserver.
Until now, I was not using Databases and hence, the deploy was running all fine.
However, now I am trying to use a MySQL database as well with this application and was wondering, if there is a possibility of deploying database, as well on remote server with Capistrano - the way it is done for Rails' databases.
Regards
Nikhil Gupta
the whole magic of database deployment is a native functionality of RoR, you might want to mimic it to get the same results.
You will need to prepare scripts for migrating your database, so do not use one script, each change of database requires a new script. You need also to store somewhere list of the already performed migrations, rails uses database table for this, but an file might be good for this too.
You might want to try with this code:
and most important to preserve order of migrations you should name your migrations with consecutive numbers or date_time, so example output of
ls -1v #{current_path}/migrations/*.sql
would look like:the date_time entries use format YYYYmmdd_hhMMss_title.sql
As far as I know there are 3 fully automatic approaches to deploy database to the production server.
I'm late to the party regarding this question but going to post anyway as this is a common question with few answers. I've had great success using Phing and Liquibase together, you can use Liquibase to roll database changes forward and backward in a highly formalized manner, and can even track your changes in version control.
I've presented on this topic several times and posted my slides (HTML format) to GitHub: https://github.com/wjgilmore/Automating-Deployments-with-Phing--Capistrano-and-Liquibase
Includes bonus material for deploying PHP websites using Capistrano. :-)