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
sudo apt-get update
Then install PostgreSQL.
sudo apt-get install postgresql postgresql-contrib libpq-dev
How to create a user for DataBase
sudo -u postgres createuser -s username
open postgres prompt
sudo -u postgres psql
Now it is time to create a new rails application
rails new nameproject -d postgresql
In config/database.yml file change
Create the database
And finally run migrations
With all of those steps, you will have your project configured to use PostgreSQL database.