Can't create table `bitwarden`.`sends` (Upgrade to 1.20.0)

Hello,

I’m running Bitwarden_RS using Docker Compose and a MySQL database.
While upgrading to the latest version 1.20.0 (bitwardenrs/server:latest) Bitwarden_RS was unable to complete the database migration. Older versions like 1.19.0 work without any problems. The errors is as follows and appears multiple times in the log.

bitwarden_1         | /--------------------------------------------------------------------\
bitwarden_1         | |                       Starting Bitwarden_RS                        |
bitwarden_1         | |                           Version 1.20.0                           |
bitwarden_1         | |--------------------------------------------------------------------|
bitwarden_1         | | This is an *unofficial* Bitwarden implementation, DO NOT use the   |
bitwarden_1         | | official channels to report bugs/features, regardless of client.   |
bitwarden_1         | | Send usage/configuration questions or feature requests to:         |
bitwarden_1         | |   https://vaultwarden.discourse.group/                             |
bitwarden_1         | | Report suspected bugs/issues in the software itself at:            |
bitwarden_1         | |   https://github.com/dani-garcia/bitwarden_rs/issues/new           |
bitwarden_1         | \--------------------------------------------------------------------/
bitwarden_1         |
bitwarden_1         | [INFO] No .env file found.
bitwarden_1         |
bitwarden_1         | Running migration 20210311190243
bitwarden_1         | Executing migration script 20210311190243/up.sql
bitwarden_1         | [2021-03-28 21:47:45.284][bitwarden_rs::util][WARN] Can't connect to database, retrying: DieselMigError.
bitwarden_1         | [CAUSE] QueryError(
bitwarden_1         |     DatabaseError(
bitwarden_1         |         __Unknown,
bitwarden_1         |         "Can\'t create table `bitwarden`.`sends` (errno: 150 \"Foreign key constraint is incorrectly formed\")",
bitwarden_1         |     ),
bitwarden_1         | )

Thanks

Please see Update to 1.18.0 Fails · Discussion #1492 · dani-garcia/bitwarden_rs · GitHub

Thanks for this link.
The character set of my database and its tables was already set according to the requirement (Update to 1.18.0 Fails · Discussion #1492 · dani-garcia/bitwarden_rs · GitHub) so this wasn’t the cause of the problem.

I’ve setup a simple empty Bitwarden_RS test instance and the migrations were executed successfully. Simple bitwarden_rs test instance with MySQL (don't use in production - just for local testing) · GitHub.

That’s why I decided just to export my data to a JSON file, drop the database, create a new empty one and then import my data. This did work flawlessly.

Sadly I didn’t find the cause of this problem, but I’ve got a suspicion. The column organizations.uuid has the data type VARCHAR(40) whereas references to it are of the data type CHAR(36).

I’ve searched in the folder migrations/mysql for all occurrences of the string organizations. In the search result you can see the different data types mentioned above.

.

Thise varchars/chars 40/36 are all fixed with subsequent migrations. And thus should not cause issues.

Please see my last post here which should solve the issue. Update to 1.18.0 Fails · Discussion #1492 · dani-garcia/bitwarden_rs · GitHub

The reason is that all text columns have separate charset and collation settings besides the tables them selfs.

1 Like