# Bug OP-11013 - After upgrade from 12.1.6 to 12.2.1: Error on db:migrate

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

## Open points

_No work packages_

## Details

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Module |  |
| Target versions |  |
| Observed in versions | 12.2.0 |
| Sprint |  |
| Backlog bucket |  |
| Bug found in version (deprecated) | 12.2.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

Precondition may be origined in certain data.

1.  Start `sudo openproject configure` after upgrade
2.  Alternatively run `sudo openproject run rake db:migrate --trace`

### What is the buggy behavior?

  - Browser gives a "503 Service Unavailable" error on browsing the OpenProject instance

### What is the expected behavior?

1.  OpenProject service is available again

### **Logs**

`sudo openproject configure` delivers following output (for complete log see attachment "output openproject configure.txt"):

``` text
I, [2022-08-21T22:06:28.736578 #484251]  INFO -- : Migrating to FixDeletedDataJournals (20220818074159)
== 20220818074159 FixDeletedDataJournals: migrating ===========================
Cleaning up journals on WorkPackage
W, [2022-08-21T22:06:28.760964 #484251]  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 1
```

`sudo openproject logs --tail` shows the following lines (snippet, see "output openproject logs.txt" for full output):

``` text
Aug 21 22:10:56 ubuntu-op systemd[1]: openproject-web-1.service: Main process exited, code=exited, status=1/FAILURE
Aug 21 22:10:56 ubuntu-op systemd[1]: openproject-web-1.service: Failed with result 'exit-code'.
Aug 21 22:10:57 ubuntu-op systemd[1]: openproject-web-1.service: Scheduled restart job, restart counter is at 7604.
Aug 21 22:10:57 ubuntu-op systemd[1]: Stopped openproject-web-1.service.
Aug 21 22:10:57 ubuntu-op systemd[1]: Started openproject-web-1.service.
Aug 21 22:11:06 ubuntu-op openproject-web-1.service[485545]: /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)
Aug 21 22:11:06 ubuntu-op openproject-web-1.service[485545]: /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)
Aug 21 22:11:06 ubuntu-op openproject-web-1.service[485545]: => Booting Puma
Aug 21 22:11:06 ubuntu-op openproject-web-1.service[485545]: => Rails 7.0.3.1 application starting in production
Aug 21 22:11:06 ubuntu-op openproject-web-1.service[485545]: => Run `bin/rails server --help` for more startup options
Aug 21 22:11:07 ubuntu-op openproject-web-1.service[485545]: Exiting
Aug 21 22:11:07 ubuntu-op openproject-web-1.service[485545]: /opt/openproject/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.3.1/lib/active_record/migration.rb:627:in `check_pending!':  (ActiveRecord::PendingMigrationError)
Aug 21 22:11:07 ubuntu-op openproject-web-1.service[485545]: Migrations are pending. To resolve this issue, run:
Aug 21 22:11:07 ubuntu-op openproject-web-1.service[485545]:         bin/rails db:migrate RAILS_ENV=production
Aug 21 22:11:07 ubuntu-op openproject-web-1.service[485545]: You have 1 pending migration:
Aug 21 22:11:07 ubuntu-op openproject-web-1.service[485545]: 20220818074159_fix_deleted_data_journals.rb
```

### 

### Environment information

**OpenProject installation type**

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

**OpenProject version**

12.2.1

**Browser**

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

**Language**

German

**Additional Information**

I already mentioned the issue in <https://community.openproject.org/topics/15250> (just to avoid confussion).
