Posted on 3 Comments

How to create PostgreSQL database for Ruby On Rails

demonstation of how to CREATE DATABASE with postgresql

This is a note to myself and those who are interested.

GERRG

I use Heroku for hosting my Ruby on Rails applications. Problem is, Heroku doesn’t support SQlite databases.

If you’ve ever tried to run rails db:migrate to create a postgesSQL database WITHOUT first setting up the databases manually, you will recognize this error:

rails aborted!
ActiveRecord::NoDatabaseError: FATAL:  database "spitter_development" does not exist

Setup a PostgreSQL database

Run the following command.

psql

If you get this error, your package manager did not setup your user account up properly.

createdb: database creation failed: ERROR:  source database "template1" is being accessed by other users

Run the createdb command.

$ createdb
$ psql
psql (10.10 (Ubuntu 10.10-0ubuntu0.18.04.1))
Type "help" for help.

Create the databases

Once you are in psql, run \list to see all the databases on your server (service)

before we add the databases

Now run the CREATE DATABASE command followed by the name of your rails applications and finally suffixed with _development and _test respectively.

Dont forget the semi-colons! ( ; )

CREATE DATABASE yourapp_development;
CREATE DATABASE yourapp_test;

Run the \list command again to confirm your databases were added correctly.

with new databases added

3 thoughts on “How to create PostgreSQL database for Ruby On Rails

  1. […] If psql didn’t work or needs to be setup, I wrote a short post about getting setup with PostgreSQL. […]

  2. erectile aids
    best ed pills
    for erectile dysfunction
    do erectile pills permanently increase size

  3. problems with erectile dysfunction
    dysfunction
    can erectile dysfunction happen suddenly

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.