I'm very new to rails, so hope this is not a stupid question.
I am trying to make rails use a postgresql database with two different user accounts. I want however to be able to switch between those accounts, so they have the same permissions on the database (without both of them being a postgresql superuser ideally).
I created a NOLOGIN
role in postgres, which is the owner of the database. Then assigned two user accounts to this role. However, whenever I do rake db:migrate
, it will make the user account (and not the role) the owner of the table. If I then switch users, the second user won't have the right permissions on the tables created by the first user.
The reason for having two account is to be able to switch quickly, e.g. when I need to change the password with no downtime.
Is there a way to tell rails to use a specific role as the owner when creating tables? (or perhaps there's a better way to accomplish this without two accounts in the same postgresql role?)
UPDATE: So far I found this solution to run manually as an external script and change ownership of all tables to the NOLOGIN role, but am hoping for something more elegant or that fits well with rails.