2

I want to migrate from sqlite3 to postgresql. After doing search I found that I should change my database.yml to somthing like that:

  adapter: postgresql
  encoding: unicode
  database: [insert your dev database name]
  pool: 5
  username: [insert your user name]
  password:

But I don't know what to provide in place of database, username and password. Because i don't remember creating any of them. I just created my rails app and migrations , and thats it.

1
  • Have you tried going to the postgres cli psql and type \du to show your roles? Then perform rake db:create? Commented Jun 16, 2015 at 4:32

1 Answer 1

2

To configure your rails project with postgres database do the below steps. provide your database details in the database.yml file eg:

development:
  username: postgres
  database: ur-db-dev
  password: pass
  encoding: UTF8
  adapter:  postgresql
  timeout:  500
  pool:     5

add postgres gem in your Gemfile

gem 'pg'

then,

  1. Do bundle install to install postgres gem
  2. rake db:create to create your database
  3. rake db:migrate to migrate your migration files
Sign up to request clarification or add additional context in comments.

2 Comments

get an error "Couldn't create database for {"adapter"=>... etc} The question is where do i get that database name,username with password. Because it says that my password is wrong for user.
in psql you create a database and use it here or create a fresh database by your rails command rake db:create. Database user name, password is you configured when you installed your postgres. use this command and login into postgres to create new user with password psql -U postgres. For more info about psql user cyberciti.biz/faq/howto-add-postgresql-user-account

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.