ruby on rails - ActiveRecord::NoDatabaseError: FATAL: database "gvpmahesh" does not exist -
i trying run rake test
getting error
rake aborted! activerecord::nodatabaseerror: fatal: database "gvpmahesh" not exist /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:661:in `rescue in connect' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_handling.rb:87:in `connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:857:in `needs_migration?' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:396:in `load_schema_if_pending!' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:411:in `block in maintain_test_schema!' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:642:in `suppress_messages' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:416:in `method_missing' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:411:in `maintain_test_schema!' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_help.rb:19:in `<top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `block in require' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require' /home/gvpmahesh/code/rails/depot/test/test_helper.rb:3:in `<top (required)>' /home/gvpmahesh/code/rails/depot/test/controllers/products_controller_test.rb:1:in `require' /home/gvpmahesh/code/rails/depot/test/controllers/products_controller_test.rb:1:in `<top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `require' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `block (3 levels) in define' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `each' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `block (2 levels) in define' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:113:in `each' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:113:in `block in define' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:20:in `invoke_rake_task' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/testing.rake:8:in `block in <top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/rake-11.2.2/exe/rake:27:in `<top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>' pg::connectionbad: fatal: database "gvpmahesh" not exist /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:438:in `new_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:448:in `checkout_new_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:571:in `retrieve_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/connection_handling.rb:87:in `connection' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:857:in `needs_migration?' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:396:in `load_schema_if_pending!' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:411:in `block in maintain_test_schema!' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:642:in `suppress_messages' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:416:in `method_missing' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activerecord-4.2.5.1/lib/active_record/migration.rb:411:in `maintain_test_schema!' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_help.rb:19:in `<top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `block in require' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:274:in `require' /home/gvpmahesh/code/rails/depot/test/test_helper.rb:3:in `<top (required)>' /home/gvpmahesh/code/rails/depot/test/controllers/products_controller_test.rb:1:in `require' /home/gvpmahesh/code/rails/depot/test/controllers/products_controller_test.rb:1:in `<top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `require' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `block (3 levels) in define' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `each' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:114:in `block (2 levels) in define' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:113:in `each' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:113:in `block in define' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/sub_test_task.rb:20:in `invoke_rake_task' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/railties-4.2.5.1/lib/rails/test_unit/testing.rake:8:in `block in <top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/gems/rake-11.2.2/exe/rake:27:in `<top (required)>' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `eval' /home/gvpmahesh/.rvm/gems/ruby-2.2.3/bin/ruby_executable_hooks:15:in `<main>' tasks: top => test:run (see full trace running task --trace)
i have in database.yml
development: &default adapter: postgresql encoding: unicode username: <%= env['db_username'] %> password: <%= env['db_password'] %> host: <%= env['db_host'] %> database: <%= env['db_name'] %> pool: <%= env['db_pool'] %> # warning: database defined "test" erased , # re-generated development database when run "rake". # not set db same development or production. test: adapter: postgresql encoding: unicode username: <%= env['db_username'] %> password: <%= env['db_password'] %> host: <%= env['db_host'] %> database: <%= env['db_test'] %> pool: <%= env['db_pool'] %> staging: <<: *default production: <<: *default
the thing development database seems work fine.
when rake db:create:all
depot_development exists depot_test exists depot_development exists depot_development exists
and have tried bundle exec rake db:create
bin/rake db:create
you're creating depot_test
within rake command.
but when run tests, have gvpmahesh
in env["db_test"]
.
so way be: set test database configuration static, , not via env variable. not sensitive information. (for git checkouts e.g.)
default: &default adapter: postgresql encoding: unicode pool: 5 timeout: 5000 # can add here credentials development: <<: *default database: depot_development test: <<: *default database: depot_test production: <<: *default database: depot_production
the advantage: if develop/test on system, don't have set db env variables , started
Comments
Post a Comment