As we developed our virtual desktop provisioning application, we had to integrate against some PHP code that wanted direct access to the database. (See next tip about that)
We started to maintain the properties of that access including low-priviledge database login, and associated limited access views for it. To do this, we initially gave our normal RoR database login the right permissions. We got less and less enamored of this:
- it gave our RoR application power that it really didn’t need.
- it made our migrations MySQL specific, and we liked to use sqlite on our laptops for development.
We couldn’t do a lot about the second point because RoR doesn’t abstract some of things we wanted to do, and sqlite doesn’t even support them. Initially, we just avoiding running those migrations that edited views, or GRANTed permissions by wrapping the code itself in:
What we decided to do was to make a new database stanza in database.yml:
We run this with:
We are looking for a way to make that the default for db:migrate, but our rake-fu isn’t high enough yet.
To make this work during capistrano deployments, we add to config/deploy.rb: