Reputation: 336
Recently, I learn to develop a rails application. Now, I have a problem. I want to change into Production Mode. But I don't want to copy my data in development database manually. How should I do these easily? I use mysql and Mac os and rails 3 beta.
Upvotes: 3
Views: 2677
Reputation: 2466
If you are using Capistrano for deployments, you can also complete this via a ruby gem capistrano-db-tasks gem.
Obviously, it is definitely great to know how to complete via underlying mysqldump commands, but once you learn this, in my personal opinion, much nicer workflow to use the gem. With the gem, you can quickly push and pull data for all of your environments, I have listed several more advantages below. I add this by default to every rails app as I am constantly pull prod data down to local.
Advantages
This allows you to run commands for push / pull for different environments in terminal:
cap production db:pull
cap production db:push # probably less common not something I would recommend
cap staging db:pull
cap staging db:push
I created a YouTube video demonstrating this gem and its advantages, thought it may be helpful if you wanted to learn more about using this gem.
Upvotes: 0
Reputation: 11876
Here are the basic commands for dumping/loading DBs in mysql:
Dumping the database:
$ mysqldump your_dev_db_name > your_db_dump.sql
Loading the dump:
$ mysql your_production_db_name < your_db_dump.sql
Upvotes: 8