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

前端 未结 2 774
暗喜
暗喜 2021-01-31 22:58

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

How to make it easier?

2条回答
  •  一整个雨季
    2021-01-31 23:49

    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

提交回复
热议问题