Rails,如何将数据从开发 sqlite3 数据库迁移到生产 MySQL 数据库?

2022-01-23 00:00:00 ruby-on-rails migration mysql sqlite

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

相关文章