Skip to content

Instantly share code, notes, and snippets.

@hoyin258
Last active April 26, 2016 14:45
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 hoyin258/06d15fa7590c5cad7b0e to your computer and use it in GitHub Desktop.
Save hoyin258/06d15fa7590c5cad7b0e to your computer and use it in GitHub Desktop.
Just a reminder for postgres setup

##Create a new user with super permission

su
sudo -u postgres psql
create user username with password 'password';
alter role username superuser createrole createdb replication;
create database projectname_production owner username;

Create new app using postgres (Rails 4.1.1)

###Local

rails new myapp --database=postgresql

###Remote

su
sudo -u postgres psql
create role myapp with createdb login password 'password1';
export MYAPP_DATABASE_PASSWORD='password1'

Useful Tips

###Get Role List

SELECT rolname FROM pg_roles;

###Drop Role

DROP ROLE myapp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment