Project

General

Profile

Actions

Bug #21815

closed

Make sure we do not try to search in permissions table when it does not exist

Added by Ondřej Pražák over 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

I encountered the following migration error on Rails 5.1:

rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "permissions" does not exist
LINE 8:                WHERE a.attrelid = '"permissions"'::regclass
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
                     c.collname, col_description(a.attrelid, a.attnum) AS comment
                FROM pg_attribute a
                LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
                LEFT JOIN pg_type t ON a.atttypid = t.oid
                LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
               WHERE a.attrelid = '"permissions"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `async_exec'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `block (2 levels) in query'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:46:in `block in permit_concurrent_loads'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activesupport-5.1.4/lib/active_support/concurrency/share_lock.rb:185:in `yield_shares'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activesupport-5.1.4/lib/active_support/dependencies/interlock.rb:45:in `permit_concurrent_loads'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:60:in `block in query'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:612:in `block (2 levels) in log'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:611:in `block in log'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activesupport-5.1.4/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:603:in `log'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql/database_statements.rb:59:in `query'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:763:in `column_definitions'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/abstract_adapter.rb:166:in `columns'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/schema_cache.rb:67:in `columns'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/connection_adapters/schema_cache.rb:73:in `columns_hash'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/model_schema.rb:471:in `load_schema!'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/attributes.rb:233:in `load_schema!'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/attribute_decorators.rb:50:in `load_schema!'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/model_schema.rb:464:in `block in load_schema'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/model_schema.rb:461:in `load_schema'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/model_schema.rb:353:in `attribute_types'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/model_schema.rb:376:in `type_for_attribute'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/table_metadata.rb:32:in `type'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/predicate_builder.rb:161:in `can_be_bound?'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/predicate_builder.rb:112:in `block in create_binds_for_hash'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/predicate_builder.rb:89:in `each'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/predicate_builder.rb:89:in `create_binds_for_hash'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/predicate_builder.rb:34:in `create_binds'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/where_clause_factory.rb:21:in `build'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/query_methods.rb:612:in `where!'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/relation/query_methods.rb:605:in `where'
/home/vagrant/.rvm/gems/ruby-2.3.4/gems/activerecord-5.1.4/lib/active_record/querying.rb:10:in `where'
/home/vagrant/foreman/app/registries/foreman/plugin.rb:273:in `add_all_permissions_to_default_roles'
/home/vagrant/foreman-tasks/lib/foreman_tasks/engine.rb:73:in `block (2 levels) in <class:Engine>'
/home/vagrant/foreman/app/registries/foreman/plugin.rb:67:in `instance_eval'
/home/vagrant/foreman/app/registries/foreman/plugin.rb:67:in `register'
/home/vagrant/foreman-tasks/lib/foreman_tasks/engine.rb:43:in `block in <class:Engine>'

Steps to reproduce:

1) switch to Rails 5.1
2) make sure you have at least one plugin that calls add_all_permissions_to_default_roles when registering
3) rake db:drop && rake db:create && rake db:migrate


Related issues 2 (0 open2 closed)

Related to Foreman - Tracker #20948: Rails 5.1 upgrade tasksClosed09/16/2017

Actions
Related to Foreman - Bug #22065: Plugin tests with Rails 5.1 fail with relation "permissions" does not existClosedOndřej Pražák12/23/2017Actions
Actions #1

Updated by Ondřej Pražák over 6 years ago

Actions #2

Updated by The Foreman Bot over 6 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/5036 added
Actions #3

Updated by Marek Hulán over 6 years ago

  • translation missing: en.field_release set to 296
Actions #4

Updated by Anonymous over 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #5

Updated by Anonymous over 6 years ago

  • Related to Bug #22065: Plugin tests with Rails 5.1 fail with relation "permissions" does not exist added
Actions

Also available in: Atom PDF