RoR/AR: advice on managing different RDBMS permissions across Rails environments
Is there a recommended practice for managing multiple testing and production database users under one Rails app? I've a Rails app with four different database users associated with it:
- owner, the DB user who owns the app schemaPermissions: Just about everything. (This is the maintenance/migration account.)
- app, the DB account that powers the web applicationPermissions: Read on most tables and views, write on some temporary caching tables.
- writer, the DB account that feedsPermissions: Write on a few tables.
- auditor, the DB account that logs DB write activityPermissions: Owns a few triggers and functions.
Right now my migration files contain GRANT/REVOKE logic for these specific, named users. However, in the "dev开发者_如何学编程elopment" environment all it is often convenient for these users to all be the very same account. Additionally, the hardcoded names of these users may conflict with already-existing DB user names in the final production environment.
It sounds like you're going to need to manage 2 different database connections for each of the classes of users you've got (app/writer). This is often managed by mixing in helpers to set these up to different classes of Models that need to use them.
There's no reason you can't configure this in your development environments, but you'll get the most bang for the buck by using a Staging environment that exactly resembles your Production environment for issues like this, where you can do a final shakedown of behavior before something is pushed live.
精彩评论