ruby-on-railspostgresqlherokunitrousionitrous

Nitrous, Heroku: create new PostgreSQL user, restrict privileges


My ultimate goal is to minimize (or eliminate, if possible) the possibility that my database records are updated or deleted/destroyed in any way after being created.

One suggestion I received is to create a new PostgreSQL database user with restricted privileges (no updating, no destroying) and make that user the default for development.

In Nitrous.io/Heroku, how do I create a new PostgreSQL user, restrict user permissions/privileges and switch to that user for development and production?

If you know a better way to eliminate the possibility for record alteration, please let me know.

Thanks


Solution

  • This isn't possible with Heroku Postgres, which I'm assuming you're using. Heroku Postgres provisions a single user account for you by default, and that's all you can use. It's up to your application logic to restrict writes / updates / deletes.

    If you need this sort of behavior guaranteed, you might want to look at either self-hosting your Postgres database, or using something like Amazon RDS to host your DB as that allows you to create users in a more fine-grained way.