9

With Rails, how do you migrate data from development sqlite3 database to production MySQL database?

How to make it easier?

0

2 Answers 2

18

You should use a gem like YamlDB. Install the Gem and then use the following rake tasks

rake db:data:dump  
RAILS_ENV=production rake db:data:load 

The first command dumps the contents of dev database to a file called db/data.yml

Also, please remember that this must be used in addition to rake db:schema:dump|load tasks as this only ports the data assuming the schema is already in place

Sign up to request clarification or add additional context in comments.

Comments

0

Assuming your database configurations are properly set up in config/database.yml, the following should get the database structure set up in production for you.

Runs against development database by default:

rake db:schema:dump

Run this against your production database by virtue of the RAILS_ENV environment variable:

rake RAILS_ENV=production db:schema:load

2 Comments

It only creates tables, but how to transfer data from these tables?
And I think It is same that rake db:migrate RAILS_ENV=production.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.