Skip to content

Instantly share code, notes, and snippets.

@fmquaglia
Created April 16, 2013 16:23
Show Gist options
  • Save fmquaglia/5397340 to your computer and use it in GitHub Desktop.
Save fmquaglia/5397340 to your computer and use it in GitHub Desktop.
This is a list of steps to get postgres installed and plugged with rails
### Aliases for postgres
pg_function() {
pg_ctl -D /usr/local/var/postgres -l logfile "$@" ;
}
alias pg="pg_function" # so now you may start and stop postgres using pg start or pg stop
###########################################################################
$ brew install postgresql
........ (lots of homebrew messages here, enjoy the colors BUT READ THE GODDAMN RELEASE NOTES, thanks :-) )
###########################################################################
$ initdb /usr/local/var/postgres -E utf8
he files belonging to this database system will be owned by user "user".
This user must also own the server process.
The database cluster will be initialized with locales
COLLATE: C
CTYPE: UTF-8
MESSAGES: C
MONETARY: C
NUMERIC: C
TIME: C
initdb: could not find suitable text search configuration for locale "UTF-8"
The default text search configuration will be set to "simple".
creating directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 1600kB
creating configuration files ... ok
creating template1 database in /usr/local/var/postgres/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
postgres -D /usr/local/var/postgres
or
pg_ctl -D /usr/local/var/postgres -l logfile start
###########################################################################
$ pg_ctl -D /usr/local/var/postgres -l logfile start
server starting
###########################################################################
$ env ARCHFLAGS="-arch x86_64" gem install pg
###########################################################################
$ psql template1
template1=# create role app_user with createdb login password 'password';
CREATE ROLE
## (just to check if the user has been created)
template1=# select * from pg_user;
usename | usesysid | usecreatedb | usesuper | usecatupd | userepl | passwd | valuntil | useconfig
----------+----------+-------------+----------+-----------+---------+----------+----------+-----------
user | 10 | t | t | t | t | ******** | |
app_user | 16384 | t | f | f | f | ******** | |
(2 rows)
## (just to check if the user has been created)
template1=# select * from pg_shadow;
usename | usesysid | usecreatedb | usesuper | usecatupd | userepl | passwd | valuntil | useconfig
----------+----------+-------------+----------+-----------+---------+------------------------------------+----------+----------
user | 10 | t | t | t | t | | |
app_user | 16384 | t | f | f | f | md5030a88627d64510d0084c41eb7c64c2 | |
(2 rows)
template1=# create database app_development owner winnow;
CREATE DATABASE
template1=# create database app_test owner winnow;
CREATE DATABASE
template1=# create database app_production owner winnow;
CREATE DATABASE
common: &common
adapter: postgresql
username: app_user
password: password # from psql setup, see Postgresql
development:
<<: *common
database: app_development
test:
<<: *common
database: app_test
production:
<<: *common
database: app_production
source 'https://rubygems.org'
gem 'rails', '3.2.13'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# gem 'sqlite3'
gem 'pg', '~> 0.15.1'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'uglifier', '>= 1.0.3'
gem 'compass-rails', '~> 1.0.3'
gem 'susy', '~> 1.0.8'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
group :test, :development do
gem 'minitest-rails'
gem 'minitest-rails-capybara'
gem 'minitest-reporters'
gem 'less-rails'
gem 'less-rails-bootstrap'
gem 'therubyracer', :platforms => :ruby
gem 'watchr'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment