开发者

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

开发者 https://www.devze.com 2023-04-01 22:59 出处:网络
With Rails, how do you migrate data from development sqlite3 database to production MySQL database? 开发者_运维技巧

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

开发者_运维技巧

How to make it easier?


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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消