[GH-ISSUE #2085] Cannot update from 1.22.2 to 1.23.0 due to database migration error #1150

Closed
opened 2026-03-03 02:06:41 +03:00 by kerem · 7 comments
Owner

Originally created by @FrankelJb on GitHub (Nov 6, 2021).
Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/2085

Subject of the issue

Updating from 1.22.2 to 1.23.0 fails with a database error:

[CAUSE] QueryError(
DatabaseError(
__Unknown,
"Can't create table `vaultwarden_db`.`emergency_access` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
),
)

Deployment environment

Your environment (Generated via diagnostics page)

  • Vaultwarden version: v1.22.2
  • Web-vault version: v2.21.1
  • Running within Docker: false
  • Environment settings overridden: true
  • Uses a reverse proxy: true
  • IP Header check: true (X-Real-IP)
  • Internet access: true
  • Internet access via a proxy: false
  • DNS Check: true
  • Time Check: true
  • Domain Configuration Check: true
  • HTTPS Check: true
  • Database type: MySQL
  • Database version: 10.5.12-MariaDB
  • Install method: Kubernetes (running k3s)

Steps to reproduce

When upgrading the container image to use vaultwarden/server:1.23.0, the database migration fails with the error. I have made no changes to the database or the connection string. I can also rollback from the failed 1.23.0 to 1.22.2 without any trouble:

DatabaseError(
[CAUSE] QueryError(
[2021-11-06 18:30:08.768][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
Executing migration script 20210830193501/up.sql
Running migration 20210830193501
)
),
[CAUSE] QueryError(
DatabaseError(
__Unknown,
"Can't create table `vaultwarden_db`.`emergency_access` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
),
)

Expected behaviour

Expected migrations to run and database to be updated.

Actual behaviour

Cannot start Vaultwarden and rollback to 1.22.2 is required.

Troubleshooting data

Originally created by @FrankelJb on GitHub (Nov 6, 2021). Original GitHub issue: https://github.com/dani-garcia/vaultwarden/issues/2085 <!-- # ### NOTE: Please update to the latest version of vaultwarden before reporting an issue! This saves you and us a lot of time and troubleshooting. See: * https://github.com/dani-garcia/vaultwarden/issues/1180 * https://github.com/dani-garcia/vaultwarden/wiki/Updating-the-vaultwarden-image # ### --> <!-- Please fill out the following template to make solving your problem easier and faster for us. This is only a guideline. If you think that parts are unnecessary for your issue, feel free to remove them. Remember to hide/redact personal or confidential information, such as passwords, IP addresses, and DNS names as appropriate. --> ### Subject of the issue Updating from 1.22.2 to 1.23.0 fails with a database error: ``` [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `vaultwarden_db`.`emergency_access` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) ``` ### Deployment environment <!-- ========================================================================================= Preferably, use the `Generate Support String` button on the admin page's Diagnostics tab. That will auto-generate most of the info requested in this section. ========================================================================================= --> <!-- The version number, obtained from the logs (at startup) or the admin diagnostics page --> <!-- This is NOT the version number shown on the web vault, which is versioned separately from vaultwarden --> <!-- Remember to check if your issue exists on the latest version first! --> ### Your environment (Generated via diagnostics page) * Vaultwarden version: v1.22.2 * Web-vault version: v2.21.1 * Running within Docker: false * Environment settings overridden: true * Uses a reverse proxy: true * IP Header check: true (X-Real-IP) * Internet access: true * Internet access via a proxy: false * DNS Check: true * Time Check: true * Domain Configuration Check: true * HTTPS Check: true * Database type: MySQL * Database version: 10.5.12-MariaDB * Install method: Kubernetes (running k3s) ### Steps to reproduce <!-- Tell us how to reproduce this issue. What parameters did you set (differently from the defaults) and how did you start vaultwarden? --> When upgrading the container image to use `vaultwarden/server:1.23.0`, the database migration fails with the error. I have made no changes to the database or the connection string. I can also rollback from the failed 1.23.0 to 1.22.2 without any trouble: ``` DatabaseError( [CAUSE] QueryError( [2021-11-06 18:30:08.768][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. Executing migration script 20210830193501/up.sql Running migration 20210830193501 ) ), [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `vaultwarden_db`.`emergency_access` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) ``` ### Expected behaviour <!-- Tell us what you expected to happen --> Expected migrations to run and database to be updated. ### Actual behaviour <!-- Tell us what actually happened --> Cannot start Vaultwarden and rollback to 1.22.2 is required. ### Troubleshooting data <!-- Share any log files, screenshots, or other relevant troubleshooting data -->
kerem closed this issue 2026-03-03 02:06:41 +03:00
Author
Owner

@BlackDex commented on GitHub (Nov 6, 2021):

Already fixed via #2080

<!-- gh-comment-id:962493221 --> @BlackDex commented on GitHub (Nov 6, 2021): Already fixed via #2080
Author
Owner

@jjlin commented on GitHub (Nov 6, 2021):

This one is actually more like #2054.

<!-- gh-comment-id:962493834 --> @jjlin commented on GitHub (Nov 6, 2021): This one is actually more like #2054.
Author
Owner

@BlackDex commented on GitHub (Nov 6, 2021):

Ah indeed, sorry for the quick mistake

<!-- gh-comment-id:962494228 --> @BlackDex commented on GitHub (Nov 6, 2021): Ah indeed, sorry for the quick mistake
Author
Owner

@FrankelJb commented on GitHub (Nov 6, 2021):

Thanks for the amazingly quick response. Incredible work on this project!

<!-- gh-comment-id:962495130 --> @FrankelJb commented on GitHub (Nov 6, 2021): Thanks for the amazingly quick response. Incredible work on this project!
Author
Owner

@MurzNN commented on GitHub (Dec 2, 2021):

Hmm, I've got this problem on upgrading from legacy bitwardenrs/server:1.17.0 to 1.23 and even 1.22.2 version (but with other tables) using mysql (mariadb), and with 1.21.0 too.
Also with testing docker tag (Version 1.23.0-ead2f02c) - the error is:

Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:40:54.925][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:40:56.004][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:40:57.103][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:40:58.175][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:40:59.267][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:00.363][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:01.575][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:02.669][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:03.777][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:04.857][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:05.948][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:07.047][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:08.163][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:09.291][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
Running migration 20210311190243
Executing migration script 20210311190243/up.sql
[2021-12-02 15:41:10.360][vaultwarden][ERROR] Error creating database pool: DieselMig.
[CAUSE] QueryError(
    DatabaseError(
        __Unknown,
        "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
    ),
)
<!-- gh-comment-id:984746970 --> @MurzNN commented on GitHub (Dec 2, 2021): Hmm, I've got this problem on upgrading from legacy bitwardenrs/server:1.17.0 to 1.23 and even 1.22.2 version (but with other tables) using mysql (mariadb), and with 1.21.0 too. Also with `testing` docker tag (Version 1.23.0-ead2f02c) - the error is: ``` Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:40:54.925][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:40:56.004][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:40:57.103][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:40:58.175][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:40:59.267][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:00.363][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:01.575][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:02.669][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:03.777][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:04.857][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:05.948][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:07.047][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:08.163][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:09.291][vaultwarden::util][WARN] Can't connect to database, retrying: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) Running migration 20210311190243 Executing migration script 20210311190243/up.sql [2021-12-02 15:41:10.360][vaultwarden][ERROR] Error creating database pool: DieselMig. [CAUSE] QueryError( DatabaseError( __Unknown, "Can't create table `my_database`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")", ), ) ```
Author
Owner

@BlackDex commented on GitHub (Dec 2, 2021):

@MurzNN this is the same issue as the OP, which has the same solution: See https://github.com/dani-garcia/vaultwarden/discussions/1559#discussioncomment-544070

<!-- gh-comment-id:984770379 --> @BlackDex commented on GitHub (Dec 2, 2021): @MurzNN this is the same issue as the OP, which has the same solution: See https://github.com/dani-garcia/vaultwarden/discussions/1559#discussioncomment-544070
Author
Owner

@MurzNN commented on GitHub (Dec 2, 2021):

Yeah, sorry for noise, have found this issue first and decided that I have the same situation, that comment fixes all for me!

<!-- gh-comment-id:984922435 --> @MurzNN commented on GitHub (Dec 2, 2021): Yeah, sorry for noise, have found this issue first and decided that I have the same situation, that comment fixes all for me!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vaultwarden#1150
No description provided.