# Bug OP-11036 - Upgrade 12.1.4 to 12.2.1 fails: pending database migration

Project: OpenProject
Status: closed
URL: https://community.openproject.org/work_packages/OP-11036

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions | 12.2.4 |
| Observed in versions | 12.1.0 |
| Sprint | 12.2.4 |
| Backlog bucket |  |
| Bug found in version (deprecated) | 12.1.x |
| Found in mobile app version |  |
| Follow-up feedback e-mail |  |
| Requires doc change | No |
| Accessibility | No |
| Pull preview |  |
| List |  |
| Labels |  |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Planning

| Attribute | Value |
| --- | --- |
| Relevance |  |

## Costs

| Attribute | Value |
| --- | --- |
| Votes |  |
| Work |  |
| Labor costs |  |

## Description

### Steps to reproduce

1.  apt-get update
2.  apt-get upgrade
3.  openproject configure
4.  Message when reloading open project  
    <img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/38116/content">

### What is the buggy behavior?

Upgrade failed.

### **Logs**

``` text
Launching installer for openproject...
Selected addons: legacy-installer openproject-edition postgres apache2 repositories memcached openproject
[legacy-installer] ./bin/configure
[openproject-edition] ./bin/configure
DONE
[postgres] ./bin/configure
DONE
[apache2] ./bin/configure
DONE
[repositories] ./bin/configure
No server installed. Skipping.
DONE
[memcached] ./bin/configure
DONE
[openproject] ./bin/configure
DONE
[legacy-installer] ./bin/preinstall
[openproject-edition] ./bin/preinstall
[postgres] ./bin/preinstall
INFO: autoinstall=skip. Skipping to next step.
[apache2] ./bin/preinstall
[repositories] ./bin/preinstall
[memcached] ./bin/preinstall
No memcached server to install. Skipping.
[openproject] ./bin/preinstall
[legacy-installer] ./bin/postinstall
[openproject-edition] ./bin/postinstall
[postgres] ./bin/postinstall
[apache2] ./bin/postinstall
[repositories] ./bin/postinstall
[memcached] ./bin/postinstall
[openproject] ./bin/postinstall
/opt/openproject/config/constants/settings/definition.rb:295:in `find_env_var_override': Using unprefixed environment variables is deprecated. Please use OPENPROJECT_ATTACHMENTS_STORAGE_PATH instead of ATTACHMENTS_STORAGE_PATH (StructuredWarnings::StandardWarning)
/opt/openproject/config/constants/settings/definition.rb:295:in `find_env_var_override': Using unprefixed environment variables is deprecated. Please use OPENPROJECT_RAILS_CACHE_STORE instead of RAILS_CACHE_STORE (StructuredWarnings::StandardWarning)
/opt/openproject/config/constants/settings/definition.rb:295:in `find_env_var_override': Using unprefixed environment variables is deprecated. Please use OPENPROJECT_ATTACHMENTS_STORAGE_PATH instead of ATTACHMENTS_STORAGE_PATH (StructuredWarnings::StandardWarning)
/opt/openproject/config/constants/settings/definition.rb:295:in `find_env_var_override': Using unprefixed environment variables is deprecated. Please use OPENPROJECT_RAILS_CACHE_STORE instead of RAILS_CACHE_STORE (StructuredWarnings::StandardWarning)
I, [2022-08-27T14:46:35.051856 #3754853]  INFO -- : Migrating to FixDeletedDataJournals (20220818074159)
== 20220818074159 FixDeletedDataJournals: migrating ===========================
Cleaning up journals on WorkPackage
W, [2022-08-27T14:46:35.062986 #3754853]  WARN -- : Scoped order is ignored, it's forced to be batch order.
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

There shouldn't be any missing data left for WorkPackage, but found 5
/opt/openproject/db/migrate/20220818074159_fix_deleted_data_journals.rb:9:in `block in up'
/opt/openproject/db/migrate/20220818074159_fix_deleted_data_journals.rb:3:in `each'
/opt/openproject/db/migrate/20220818074159_fix_deleted_data_journals.rb:3:in `up'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:873:in `public_send'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:873:in `exec_migration'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:853:in `block in migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:852:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1046:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/transactions.rb:209:in `transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1411:in `ddl_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `each'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1117:in `up'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1092:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <top (required)>'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/sentry-ruby-core-5.3.1/lib/sentry/rake.rb:24:in `execute'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli/exec.rb:58:in `load'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli/exec.rb:58:in `kernel_load'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli/exec.rb:23:in `run'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli.rb:483:in `exec'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli.rb:31:in `dispatch'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli.rb:25:in `start'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/exe/bundle:48:in `block in <top (required)>'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/exe/bundle:36:in `<top (required)>'
/opt/openproject/bin/bundle:110:in `load'
/opt/openproject/bin/bundle:110:in `<main>'

Caused by:
There shouldn't be any missing data left for WorkPackage, but found 5
/opt/openproject/db/migrate/20220818074159_fix_deleted_data_journals.rb:9:in `block in up'
/opt/openproject/db/migrate/20220818074159_fix_deleted_data_journals.rb:3:in `each'
/opt/openproject/db/migrate/20220818074159_fix_deleted_data_journals.rb:3:in `up'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:873:in `public_send'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:873:in `exec_migration'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:854:in `block (2 levels) in migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:853:in `block in migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:852:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1046:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1360:in `block in execute_migration_in_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.3.1/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/database_statements.rb:316:in `transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/transactions.rb:209:in `transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1411:in `ddl_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1359:in `execute_migration_in_transaction'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `each'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1333:in `migrate_without_lock'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `block in migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1432:in `block in with_advisory_lock'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:215:in `with_connection'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1447:in `with_advisory_lock_connection'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1428:in `with_advisory_lock'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1282:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1117:in `up'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:1092:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/tasks/database_tasks.rb:262:in `migrate'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/railties/databases.rake:92:in `block (2 levels) in <top (required)>'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/sentry-ruby-core-5.3.1/lib/sentry/rake.rb:24:in `execute'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli/exec.rb:58:in `load'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli/exec.rb:58:in `kernel_load'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli/exec.rb:23:in `run'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli.rb:483:in `exec'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli.rb:31:in `dispatch'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/cli.rb:25:in `start'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/exe/bundle:48:in `block in <top (required)>'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/opt/openproject/vendor/bundle/ruby/3.1.0/gems/bundler-2.3.10/exe/bundle:36:in `<top (required)>'
/opt/openproject/bin/bundle:110:in `load'
/opt/openproject/bin/bundle:110:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
```

### 

### Environment information

**OpenProject installation type**

- [ ] Hosted cloud edition
- [x] Packaged installation
    - What distribution? Ubuntu
- [ ] Docker All-in-one container
- [ ] Docker-compose installation
- [ ] Other (please specify)

**OpenProject version**

*v12.1.4*

**Browser**

- [ ] Chrome
- [ ] Firefox
- [x] Safari
- [ ] Mobile Safari
- [ ] Other (please specify)

**Language**

Browser language NL OpenProject EN

Looking back at versions between 12.1.4 and 12.2.1 there seems no database migration necessary. What can I do to fix the issue?
