Setting up Postgres for a Rails site

19 February 2015

Here’s a quick solution adding a specific user (aka role) in Postgres.

If your rake complains

ActiveRecord::NoDatabaseError (FATAL:  role "<appName>" does not exist
Run $ bin/rake db:create db:migrate to create your database):

or similar. Try the following.

createdb <appName>

You may need to setup a user in Postgres for the project.

Run createuser <appName>.

Add -s if you get an error about the user not being able to create databases createuser <appName> -s.

If you need to delete this user run dropuser <appName>.

And for completeness to drop a database dropdb <appName>.

There’s a very convenient util pg_ctl. Use pg_ctl init <database name>. to make a new database. pg_ctl start -l logfile to start postgres and move it to the background.

If you need help solving your business problems with software read how to hire me.

comments powered by Disqus