ixti / redmine_tags

Redmine plugin, that adds issues tagging support
GNU General Public License v3.0
196 stars 119 forks source link

[master] Can't install a fresh Redmine 4.1.x with redmine_tags already present #237

Open danowar2k opened 2 years ago

danowar2k commented 2 years ago

When one installs a new Redmine 4.1.x (i.e. the database is still empty) and redmine_tags is already present in the plugins directory, one can't run rake db:migrate to create the database structure because the patch at https://github.com/ixti/redmine_tags/blob/master/lib/redmine_tags/patches/issue_query_patch.rb

uses the IssueQuery class which can't be used once the database structure is created.

This leads to the following error:

/usr/bin/bundle _2.3.23_ exec rake db:migrate
    rake aborted!
    ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "users" does not exist
    LINE 8:                WHERE a.attrelid = '"users"'::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 = '"users"'::regclass
                     AND a.attnum > 0 AND NOT a.attisdropped
                   ORDER BY a.attnum
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `async_exec'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql_adapter.rb:757:in `column_definitions'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:113:in `columns'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/schema_cache.rb:69:in `columns'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/schema_cache.rb:75:in `columns_hash'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:466:in `load_schema!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/attributes.rb:234:in `load_schema!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:459:in `block in load_schema'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:456:in `load_schema'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:336:in `columns_hash'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/inheritance.rb:78:in `descends_from_active_record?'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/inheritance.rb:84:in `finder_needs_type_condition?'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/core.rb:287:in `relation'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/scoping/default.rb:34:in `unscoped'
    /var/redmine/code/4.1.7/app/models/user.rb:822:in `anonymous'
    /var/redmine/code/4.1.7/app/models/user.rb:816:in `current'
    /var/redmine/code/4.1.7/app/models/query.rb:91:in `groupable'
    /var/redmine/code/4.1.7/app/models/query.rb:31:in `initialize'
    /var/redmine/code/4.1.7/app/models/issue_query.rb:36:in `new'
    /var/redmine/code/4.1.7/app/models/issue_query.rb:36:in `<class:IssueQuery>'
    /var/redmine/code/4.1.7/app/models/issue_query.rb:20:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `block in require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:257:in `load_dependency'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:356:in `require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:510:in `load_missing_constant'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:195:in `const_missing'
    /var/redmine/code/4.1.7/plugins/redmine_tags/lib/redmine_tags/patches/issue_query_patch.rb:56:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `block in require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:257:in `load_dependency'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:356:in `require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:334:in `depend_on'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:246:in `require_dependency'
    /var/redmine/code/4.1.7/plugins/redmine_tags/init.rb:8:in `block (2 levels) in <top (required)>'
    /var/redmine/code/4.1.7/plugins/redmine_tags/init.rb:7:in `each'
    /var/redmine/code/4.1.7/plugins/redmine_tags/init.rb:7:in `block in <top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:426:in `instance_exec'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:605:in `catch'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:199:in `block in halting'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:513:in `each'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:513:in `invoke_before'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/reloader.rb:89:in `prepare!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application/finisher.rb:63:in `block in <module:Finisher>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:32:in `instance_exec'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:32:in `run'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:61:in `block in run_initializers'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:60:in `run_initializers'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:361:in `initialize!'
    /var/redmine/code/4.1.7/config/environment.rb:16:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:337:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:337:in `require_environment!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:58:in `load'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:58:in `kernel_load'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:23:in `run'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli.rb:486:in `exec'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli.rb:31:in `dispatch'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli.rb:25:in `start'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/exe/bundle:48:in `block in <top (required)>'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/exe/bundle:36:in `<top (required)>'
    /usr/bin/bundle:23:in `load'
    /usr/bin/bundle:23:in `<main>'

    Caused by:
    PG::UndefinedTable: ERROR:  relation "users" does not exist
    LINE 8:                WHERE a.attrelid = '"users"'::regclass
                                              ^
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `async_exec'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:63:in `block (2 levels) in query'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:62:in `block in query'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract_adapter.rb:581:in `block (2 levels) in log'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract_adapter.rb:580:in `block in log'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract_adapter.rb:571:in `log'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql/database_statements.rb:61:in `query'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/postgresql_adapter.rb:757:in `column_definitions'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:113:in `columns'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/schema_cache.rb:69:in `columns'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/connection_adapters/schema_cache.rb:75:in `columns_hash'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:466:in `load_schema!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/attributes.rb:234:in `load_schema!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/attribute_decorators.rb:51:in `load_schema!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:459:in `block in load_schema'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:456:in `load_schema'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/model_schema.rb:336:in `columns_hash'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/inheritance.rb:78:in `descends_from_active_record?'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/inheritance.rb:84:in `finder_needs_type_condition?'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/core.rb:287:in `relation'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activerecord-5.2.6.3/lib/active_record/scoping/default.rb:34:in `unscoped'
    /var/redmine/code/4.1.7/app/models/user.rb:822:in `anonymous'
    /var/redmine/code/4.1.7/app/models/user.rb:816:in `current'
    /var/redmine/code/4.1.7/app/models/query.rb:91:in `groupable'
    /var/redmine/code/4.1.7/app/models/query.rb:31:in `initialize'
    /var/redmine/code/4.1.7/app/models/issue_query.rb:36:in `new'
    /var/redmine/code/4.1.7/app/models/issue_query.rb:36:in `<class:IssueQuery>'
    /var/redmine/code/4.1.7/app/models/issue_query.rb:20:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `block in require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:257:in `load_dependency'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:356:in `require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:510:in `load_missing_constant'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:195:in `const_missing'
    /var/redmine/code/4.1.7/plugins/redmine_tags/lib/redmine_tags/patches/issue_query_patch.rb:56:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `block in require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:257:in `load_dependency'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:291:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:378:in `block in require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `block in load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies/interlock.rb:13:in `loading'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:37:in `load_interlock'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:356:in `require_or_load'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:334:in `depend_on'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/dependencies.rb:246:in `require_dependency'
    /var/redmine/code/4.1.7/plugins/redmine_tags/init.rb:8:in `block (2 levels) in <top (required)>'
    /var/redmine/code/4.1.7/plugins/redmine_tags/init.rb:7:in `each'
    /var/redmine/code/4.1.7/plugins/redmine_tags/init.rb:7:in `block in <top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:426:in `instance_exec'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:426:in `block in make_lambda'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:198:in `block (2 levels) in halting'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:606:in `block (2 levels) in default_terminator'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:605:in `catch'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:605:in `block in default_terminator'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:199:in `block in halting'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:513:in `block in invoke_before'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:513:in `each'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:513:in `invoke_before'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/callbacks.rb:131:in `run_callbacks'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/activesupport-5.2.6.3/lib/active_support/reloader.rb:89:in `prepare!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application/finisher.rb:63:in `block in <module:Finisher>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:32:in `instance_exec'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:32:in `run'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:61:in `block in run_initializers'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/initializable.rb:60:in `run_initializers'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:361:in `initialize!'
    /var/redmine/code/4.1.7/config/environment.rb:16:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:337:in `require'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:337:in `require_environment!'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/railties-5.2.6.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
    /var/redmine/code/4.1.7/.appgems/ruby/2.6.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:58:in `load'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:58:in `kernel_load'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli/exec.rb:23:in `run'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli.rb:486:in `exec'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli.rb:31:in `dispatch'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/cli.rb:25:in `start'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/exe/bundle:48:in `block in <top (required)>'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
    /var/redmine/code/4.1.7/.appgems/gems/bundler-2.3.23/exe/bundle:36:in `<top (required)>'
    /usr/bin/bundle:23:in `load'
    /usr/bin/bundle:23:in `<main>'
    Tasks: TOP => db:migrate => db:load_config => environment
    (See full trace by running task with --trace)

This was a Redmine issue (https://www.redmine.org/issues/33290) which was fixed in 4.2.x but maybe one can do something for 4.1.x, too.

I don't know if there would be way to only do the patch if the database structure has been created...