Today I’ve migrated the database of Ruby on Rails project from Sqlite to MySQL. It’s not first time I’ve done it. So, I decided to note it as a post.
First of all, it needs to add special yaml_db gem to the project:
It allows us to dump all data from the storage by command like:
RAILS_ENV=production rake db:dump
then switch the storage (production inour case) from Sqlite to MySQL in config/database.yml file and load the data back to the storage:
RAILS_ENV=production rake db:load
in this case into MySQL backend.
It’s a preferred way of such migration because of its pure abstract yaml representation of the data. It doesn’t depend on specific SQL.