Skip to content

Instantly share code, notes, and snippets.

@vedant1811
Last active September 4, 2018 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vedant1811/eb4bf07f81471bb325d11541e1da55e0 to your computer and use it in GitHub Desktop.
Save vedant1811/eb4bf07f81471bb325d11541e1da55e0 to your computer and use it in GitHub Desktop.
Setup postgres for rails dev (mac & ubuntu)
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
host: localhost
username: rails
password: rails
development:
<<: *default
database: bowling_development
test:
<<: *default
database: bowling_test
$ brew install postgresql
$ brew services start postgresql
==> Tapping homebrew/services
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'...
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 14 (delta 0), reused 7 (delta 0), pack-reused 0
Unpacking objects: 100% (14/14), done.
Tapped 1 command (44 files, 58.4KB).
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
$ psql postgres
postgres=# create user rails with password 'rails';
CREATE ROLE
postgres=# alter role rails superuser createrole createdb replication;
ALTER ROLE
<CTRL+D to exit cli>
$ rails db:create
Created database 'bowling_development'
Created database 'bowling_test'
$ sudo apt install postgresql postgresql-contrib
$ sudo -u postgres psql
postgres=#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment