I can’t convert Rails app from sqlite to postgres (to deploy Heroku)

Asked

Viewed 81 times

2

I’ve been trying to convert a rails app in sqlite for postgres in order to use it on Heroku, following this tutorial from Heroku himself: https://devcenter.heroku.com/articles/sqlite3

Only when I’m going to create a DB using the rake db:create, I have this error message:

rake db:create

FATAL: role "caiograco" does not exist

("caiograco" is my username on Linux. I don’t know how it went there)

  • 1

    Role is how a user is treated in Postgresql. If Voce does not define the user at the time of execution psql he understands that it is to use the user who executed it. You must pass the user information owner or who owns permission on the basis.

1 answer

1

As stated in Soen you must add the username for your database.yml, could very well use your application name (or some variant of the name) as the username, I will use app_name as a reserved space:

development:
  adapter: postgresql
  encoding: utf8
  database: app_development
  pool: 5
  username: app_name
  password:

You should also create the same "role" user in Postgresql using psql:

$ psql -d postgres
postgres=# create role app_name login createdb;
postgres=# \q

The first line runs on your terminal, the following are inside the postgres. So after this try to run the rake db:create.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.