Re: Ubuntu and Rails postgresql setup

From: Paul Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Ubuntu and Rails postgresql setup
Date: 2016-02-24 17:44:37
Message-ID: 56CDEC05.8030506@illuminatedcomputing.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 02/24/2016 12:34 AM, Marco Lobbia wrote:
> I am on a Ubuntu 14.04 LTS machine.

I thought I'd chime in since I work with Rails and Postgres on Ubuntu
all day long. :-) 14.04 LTS is fine for both production and development.
(Sounds like you're using Heroku for production in any case.)

> Putting everything together, all the information seems to converge on
> the necessity of creating a database superuser with login name that
> match my Ubuntu user name with:
>
> |sudo -u postgres createuser --superuser $USER|

This is the "normal" way to do it for Rails. It wants a superuser so it
can drop and recreate the database before running tests (`rake test`).
Personally I prefer to give each project a separate non-superuser
Postgres account and start tests with just `rspec spec`, but if you're
new to Rails I recommend going with the approved method.

Also, Rails wants to use Postgres "ident" authentication, which does not
require a password because it trusts that the OS has already
authenticated you. You can avoid this too if you like by adding `host:
localhost` to your `database.yml`, but then you'll need to use a password.

Btw since this is not the Rails mailing list, feel free to email me
personally if you have more Rails-specific questions.

> According to Heroku
> <https://devcenter.heroku.com/articles/heroku-postgresql#local-setup>
> it is necessary "to export the DATABASE_URL environment variable for
> your app to connect to it when running locally", with:
> |export DATABASE_URL=postgres:///$(whoami)|

That is if you want to connect to the *remote* database on Heroku (i.e.
probably your *production* database). If you want to connect to your
locally-installed Postgres, you should not set DATABASE_URL.

> Finally I am wondering whether the choice of installing PostgreSQL
> through the PostgreSQL apt repository would be safe enough or it would
> be preferable to install the LTS version of Ubuntu.

Either is fine.

Good luck!
Paul

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Guthrie 2016-02-24 17:51:17 "plan should not reference subplan's variable" when using row level security
Previous Message Bala Venkat 2016-02-24 15:41:24 Re: Perfomance issue. statement in the log file..