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.
Some time ago I designed and implemented mobile solution to browse/search legal information actual in the Netherlands. There are a lot of legal institutions, rules, etc. in the Netherlands, so, the idea of application is to provide the roadmap for regular user to solve specified law question/problem.
There is a client-server solution. From one hand there is free android application which can be used as offline manual. As it’s mostly content oriented application, I created it by PhoneGap + HTML5 + jQueryMobile technology. But it’s not pure HTML5/JS/CSS solution because it needs several PhoneGap plugins implemented by Java.
Server side of the solution is a simple PHP+MySQL CMS implemented as single-page backbone.js web application to compose and correct the content of the manual. I also used Slim MVC, Twig templates and idiorm ORM to MySQL frameworks.
The workflow is:
- Content manager edits the content (CRUD) and deploy new version available via HTTP online;
- The clients automatically update (check, download and install) the latest version of content from that HTTP interface when they are online;
- Then the clients may use new content even offline.
There are also such useful features:
- search by tags
- feedback form
- share the link/content via email/facebook/twitter/etc.