Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

rake db:create throws error in Rails 5 #81

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jspooner
Copy link

Expected behavior:

rake db:create runs as normal

Actual behavior:

rake db:drop
rake aborted!
ActiveRecord::NoDatabaseError: FATAL:  database "foo_development" does not exist
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:688:in `rescue in connect'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:683:in `connect'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:215:in `initialize'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `new'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:40:in `postgresql_connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:809:in `new_connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `checkout_new_connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:832:in `try_to_checkout_new_connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:793:in `acquire_connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:521:in `checkout'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:380:in `connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:1008:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/connection_handling.rb:90:in `connection'
/usr/local/rvm/gems/ruby-2.4.4/gems/activerecord-5.2.1/lib/active_record/model_schema.rb:324:in `table_exists?'
/usr/local/rvm/gems/ruby-2.4.4/gems/bitmask_attributes-1.0.0/lib/bitmask_attributes/definition.rb:29:in `validate_for'
/usr/local/rvm/gems/ruby-2.4.4/gems/bitmask_attributes-1.0.0/lib/bitmask_attributes/definition.rb:14:in `install_on'
/usr/local/rvm/gems/ruby-2.4.4/gems/bitmask_attributes-1.0.0/lib/bitmask_attributes.rb:25:in `bitmask'
/home/app/webapp/app/models/user.rb:16:in `<class:User>'
/home/app/webapp/app/models/user.rb:4:in `<top (required)>'
......... SNIP .....................
Tasks: TOP => db:drop => db:load_config => environment
(See full trace by running task with --trace)
**Airbrake: closed

During rake `db:create` on a Rails 5 project model.table_exists? raises an ActiveRecord::NoDatabaseError
When running `rake db:create` from a rails-5 app `model.table_exists?` raises a ActiveRecord::NoDatabaseError
@BBBernsteyn
Copy link

BBBernsteyn commented Nov 6, 2018

I can confirm that this is

  1. indeed an issue and
  2. a viable fix.

The situation is similar when running rake assets:precompile.

@jspooner Thanks for sharing!

@DmytroStepaniuk
Copy link

Is this repo still alive? 🤔

@joelmoss
Copy link
Owner

No sorry. Use Rails ActiveRecord enums instead.

@DmytroStepaniuk
Copy link

DmytroStepaniuk commented Nov 29, 2018

No sorry. Use Rails ActiveRecord enums instead.

Well, AR enum doesn't offer bit masks features as far as I know 🤔

So, for example, having 2 roles admin and manager, U would generate enum like

enum {
  admin: 0,
  manager: 1,
  admin_and_manager: 2
}

Like that? 🤔Right?

@ydakuka
Copy link

ydakuka commented Apr 9, 2020

Use active_flag gem instead.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants