Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running rake spec on new rails app without a migration #6

Open
esambo opened this issue Jan 30, 2017 · 0 comments
Open

Error running rake spec on new rails app without a migration #6

esambo opened this issue Jan 30, 2017 · 0 comments

Comments

@esambo
Copy link
Contributor

esambo commented Jan 30, 2017

Error

PG::ObjectInUse: ERROR:  database "foo_test" is being accessed by other users
DETAIL:  There is 1 other session using the database.
: DROP DATABASE IF EXISTS "foo_test"
Couldn't drop database 'foo_test'
rails aborted!
ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  database "foo_test" is being accessed by other users
DETAIL:  There is 1 other session using the database.
: DROP DATABASE IF EXISTS "foo_test"
PG::ObjectInUse: ERROR:  database "foo_test" is being accessed by other users
DETAIL:  There is 1 other session using the database.

New rails app with RSpec

bundle exec rake --trace

without prodder (works fine without an error)

** Invoke spec (first_time)
** Invoke spec:prepare (first_time)
** Execute spec:prepare
** Execute spec

with prodder (errors)

** Invoke spec (first_time)
** Invoke spec:prepare (first_time)
** Execute spec:prepare
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Execute db:test:prepare
** Invoke db:reset (first_time)
** Invoke db:drop (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:drop
No permissions file (db/permissions.sql) found, running everything in context of user
Dropped database 'foo_test'
** Invoke db:setup (first_time)
** Invoke db:create (first_time)
** Invoke db:load_config
** Execute db:create
No permissions file (db/permissions.sql) found, running everything in context of user
Created database 'foo_test'
** Invoke db:structure:load (first_time)
** Invoke db:load_config
** Execute db:structure:load
Loading db/structure.sql into database 'foo_test'
** Invoke db:seed (first_time)
** Invoke db:load_config
** Execute db:seed
db/seeds.sql not found: no seeds to load.
** Invoke db:quality_check (first_time)
** Invoke db:load_config
** Execute db:quality_check
db/quality_checks.sql not found: no quality_checks to load.
** Invoke db:permission (first_time)
** Invoke db:load_config
** Execute db:permission
db/permissions.sql not found: no permissions to load.
** Invoke db:settings (first_time)
** Invoke db:load_config
** Execute db:settings
Loading db/settings.sql into database 'foo_test'
** Execute db:setup
** Execute db:reset
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config
** Execute db:migrate
No permissions file (db/permissions.sql) found, running everything in context of user
** Execute test:prepare
** Execute spec
~/.rubies/ruby-2.3.3/bin/ruby -I~/.gem/ruby/2.3.3/gems/rspec-core-3.5.4/lib:~/.gem/ruby/2.3.3/gems/rspec-support-3.5.0/lib ~/.gem/ruby/2.3.3/gems/rspec-core-3.5.4/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb
No permissions file (db/permissions.sql) found, running everything in context of user
PG::ObjectInUse: ERROR:  database "foo_test" is being accessed by other users
DETAIL:  There is 1 other session using the database.
: DROP DATABASE IF EXISTS "foo_test"
Couldn't drop database 'foo_test'
rails aborted!
ActiveRecord::StatementInvalid: PG::ObjectInUse: ERROR:  database "foo_test" is being accessed by other users
DETAIL:  There is 1 other session using the database.
: DROP DATABASE IF EXISTS "foo_test"
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
~/.gem/ruby/2.3.3/gems/activesupport-5.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:70:in `drop_database'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/postgresql_database_tasks.rb:28:in `drop'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:136:in `drop'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:152:in `block in drop_current'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:292:in `block in each_current_configuration'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:291:in `each'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:291:in `each_current_configuration'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:151:in `drop_current'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:156:in `block (3 levels) in <top (required)>'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:368:in `as'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:155:in `block (2 levels) in <top (required)>'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:295:in `block (3 levels) in <top (required)>'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:5:in `require'
bin/rails:5:in `<main>'
PG::ObjectInUse: ERROR:  database "foo_test" is being accessed by other users
DETAIL:  There is 1 other session using the database.
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `async_exec'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `block in execute'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:589:in `block in log'
~/.gem/ruby/2.3.3/gems/activesupport-5.0.1/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:583:in `log'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:97:in `execute'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/connection_adapters/postgresql/schema_statements.rb:70:in `drop_database'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/postgresql_database_tasks.rb:28:in `drop'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:136:in `drop'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:152:in `block in drop_current'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:292:in `block in each_current_configuration'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:291:in `each'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:291:in `each_current_configuration'
~/.gem/ruby/2.3.3/gems/activerecord-5.0.1/lib/active_record/tasks/database_tasks.rb:151:in `drop_current'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:156:in `block (3 levels) in <top (required)>'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:368:in `as'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:155:in `block (2 levels) in <top (required)>'
~/.gem/ruby/2.3.3/gems/prodder-1.7.1/lib/prodder/prodder.rake:295:in `block (3 levels) in <top (required)>'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:14:in `block in run_rake_task'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands/rake_proxy.rb:11:in `run_rake_task'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:51:in `run_command!'
~/.gem/ruby/2.3.3/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:5:in `require'
bin/rails:5:in `<main>'
Tasks: TOP => db:reset => db:drop

Workaround

Add an empty migration

def up
  say 'Prodder wants at least one migration'
end

def down
  fail ActiveRecord::IrreversibleMigration
end

Potential fixes

  1. Fix it and have it do nothing just like plain active_record would do
  2. Document it in the README
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant