Guest User

Untitled

a guest
Dec 3rd, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. Cloud9 does not run PG by defalut. Below is the fast & easy way I use to use Postgresql on C9:
  2.  
  3. 1. Gemfile.rb:
  4. gem 'pg'
  5.  
  6. 2. Database.yml:
  7. default: &default
  8. adapter: postgresql
  9. encoding: unicode
  10. pool: 5
  11. username: my_name
  12. password: my_pass
  13. host: <%= ENV['IP'] %>
  14.  
  15. development:
  16. <<: *default
  17. database: my_db_development
  18.  
  19. test:
  20. <<: *default
  21. database: my_db_test
  22.  
  23. production:
  24. <<: *default
  25. database: my_db_production
  26.  
  27. 3.Paste the following code alltogether in the console:
  28. -----------------------------------------------------------------
  29. sudo service postgresql start
  30. sudo sudo -u postgres psql
  31. CREATE USER my_name SUPERUSER PASSWORD 'my_pass';
  32. \q
  33. echo "export USERNAME=my_name"
  34. echo "export PASSWORD=my_pass"
  35. source
  36. bundle
  37. sudo sudo -u postgres psql
  38. UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
  39. DROP DATABASE template1;
  40. CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
  41. UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
  42. \c template1
  43. VACUUM FREEZE;
  44. \q
  45. bundle exec rake db:create
  46. rake db:migrate
  47. --------------------------------------------------------------------------------------------
  48. Done! However after not using the app for some hours the db goes to sleep & you have to "switch" Postgres on manually by typing
  49. in the console: sudo service postgresql start
Add Comment
Please, Sign In to add comment