ruby on rails - Trying to switch from SQLite to PostgreSQL -


i using sqlite in development , test, , postgresql in production on heroku. replace sqlite postgresql. programming in cloud9 environment (rails 4). have no data potentially lose.

what did do:

first, edited database.yml:

default: &default       adapter: postgresql       encoding: unicode       pool: 5 development:   <<: *default   database: app_development test:   <<: *default   database: app_test production:   <<: *default   database: app_production 

then:

  • in gemfile moved gem 'pg' production environment environments , removed gem 'sqlite3'
  • i ran bundle install.
  • i ran sudo service postgresql start
  • i ran sudo sudo -u postgres psql
  • and entered create database "app_development";
  • entered \q

update: added following additional steps:

  • i created new user in psql create user my_username superuser password 'my_password';
  • in database.yml added username , password
  • in database.yml added host: myurl.c9.io
  • i entered in psql: grant on database app_development my_username

running sudo sudo -u postgres psql , \list produces:

      name          |  owner   | encoding  | collate | ctype |   access privileges     postgres           | postgres | sql_ascii | c       | c     |   template0          | postgres | sql_ascii | c       | c     | =c/postgres          +                     |          |           |         |       | postgres=ctc/postgres  template1          | postgres | sql_ascii | c       | c     | =c/postgres          +                     |          |           |         |       | postgres=ctc/postgres  app_development    | postgres | sql_ascii | c       | c     |  

i don't see username here owner of app_development...

error: running rake db:migrate times out, stating pg::connectionbad: not connect server: connection timed out server running on host "myurl.c9.io" (ip address) , accepting tcp/ip connections on port 5432?.

why might connection postgresql failing?

replace content of database.yml file to:

default: &default   adapter: postgresql   host: localhost   username: yourusername   password: yourpassword   timeout: 5000   port: 5432 development:   <<: *default   database: app_development test:   <<: *default   database: app_test production:   <<: *default   database: app_production 

because use heroku can leave production section is


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -