Roles in PostgreSQL by makaroni4
Sometimes in #rails you don't want to touch database.yml file and to leave username and password as they were. But migrations will fail because you don't have a role (username and password like in your database.yml).
In #postgresql a role is some kind of user which can access the database. To list all the roles use \du command.
Try to create new role:
CREATE ROLE new_role WITH PASSWORD 'new_pass';
And if you run \du command you will see, that new_role is not allowed to log in and if you try to run you migrations you will have an error. To allow role to login you must specify LOGIN option:
CREATE ROLE new_role WITH LOGIN PASSWORD 'new_pass';
Also you can specify not only LOGIN option. There are several more options like SUPERUSER, list of all options available here
CREATE ROLE new_role WITH LOGIN SUPERUSER PASSWORD 'new_pass';
To drop the role use:
DROP ROLE new_role;
Comments
releu commented about 1 year ago
thanks =)