Postgres on Ruby on Rails

In my last post, I wrote about Ruby on Rails 
Ruby on Rails uses SQLite3 as default. In many cases that database is enough but if you want to use Heroku you will need to use Postgres instead. In the past Heroku worked with SQLite3 but now it only works with Postgres, so in this post I am going to explain how to change your database from SQLite3 to Postgres in a Ruby on Rails project

First, update

sudo apt-get update

Then install PostgreSQL.

sudo apt-get install postgresql postgresql-contrib libpq-dev

How to create a user for DataBase
User name

sudo -u postgres createuser -s username

open postgres prompt

sudo -u postgres psql

Postgres prompt

\password pgpassword

Now it is time to create a new rails application

rails new nameproject -d postgresql

In config/database.yml file change

username: name
password: password

Create the database

rake db:create

And finally run migrations

rake db:migrate

With all of those steps, you will have your project configured to use PostgreSQL database.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.