Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Cloud9 does not run PG by defalut. Below is the fast & easy way I use to use Postgresql on C9:
- 1. Gemfile.rb:
- gem 'pg'
- 2. Database.yml:
- default: &default
- adapter: postgresql
- encoding: unicode
- pool: 5
- username: my_name
- password: my_pass
- host: <%= ENV['IP'] %>
- development:
- <<: *default
- database: my_db_development
- test:
- <<: *default
- database: my_db_test
- production:
- <<: *default
- database: my_db_production
- 3.Paste the following code alltogether in the console:
- -----------------------------------------------------------------
- sudo service postgresql start
- sudo sudo -u postgres psql
- CREATE USER my_name SUPERUSER PASSWORD 'my_pass';
- \q
- echo "export USERNAME=my_name"
- echo "export PASSWORD=my_pass"
- source
- bundle
- sudo sudo -u postgres psql
- UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
- DROP DATABASE template1;
- CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
- UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
- \c template1
- VACUUM FREEZE;
- \q
- bundle exec rake db:create
- rake db:migrate
- --------------------------------------------------------------------------------------------
- Done! However after not using the app for some hours the db goes to sleep & you have to "switch" Postgres on manually by typing
- in the console: sudo service postgresql start
Add Comment
Please, Sign In to add comment