[PR #493] [MERGED] Initial support for mysql #3701

Open
opened 2025-10-09 18:28:24 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/493
Author: @endyman
Created: 5/27/2019
Status: Merged
Merged: 6/2/2019
Merged by: @dani-garcia

Base: masterHead: feature/initial_mysql_support


📝 Commits (10+)

  • 42af7c6 MySQL database
  • 85c8a01 Merge branch 'master' of github.com:Skeen/bitwarden_rs
  • ab95a69 Rework migrations for MySQL
  • e22e290 Fix key and type variable names for mysql
  • 233b48b Fix missing joinable in schema
  • eb9d5e1 Reintroduce .env.template
  • 5fb6531 Attempt to fix azure pipeline
  • 6f78395 Passwordless sudo on azure?
  • badd22a Make docker image build
  • ff75939 initial mysql support

📊 Changes

75 files changed (+610 additions, -134 deletions)

View changed files

📝 .travis.yml (+3 -1)
📝 Cargo.lock (+12 -13)
📝 Cargo.toml (+6 -4)
📝 Dockerfile (+12 -2)
📝 Dockerfile.aarch64 (+7 -2)
📝 Dockerfile.alpine (+15 -2)
📝 Dockerfile.armv6 (+7 -2)
📝 Dockerfile.armv7 (+8 -2)
📝 azure-pipelines.yml (+10 -2)
📝 migrations/mysql/2018-01-14-171611_create_tables/down.sql (+0 -0)
migrations/mysql/2018-01-14-171611_create_tables/up.sql (+62 -0)
📝 migrations/mysql/2018-02-17-205753_create_collections_and_orgs/down.sql (+0 -0)
migrations/mysql/2018-02-17-205753_create_collections_and_orgs/up.sql (+30 -0)
📝 migrations/mysql/2018-04-27-155151_create_users_ciphers/down.sql (+0 -0)
migrations/mysql/2018-04-27-155151_create_users_ciphers/up.sql (+34 -0)
📝 migrations/mysql/2018-05-08-161616_create_collection_cipher_map/down.sql (+0 -0)
migrations/mysql/2018-05-08-161616_create_collection_cipher_map/up.sql (+5 -0)
📝 migrations/mysql/2018-05-25-232323_update_attachments_reference/down.sql (+0 -0)
migrations/mysql/2018-05-25-232323_update_attachments_reference/up.sql (+14 -0)
📝 migrations/mysql/2018-06-01-112529_update_devices_twofactor_remember/down.sql (+0 -0)

...and 55 more files

📄 Description

This is a merged PR based on the work of @skeen in #486 and our efforts to support additional backends.

Using build args the desired backend can be selected, the default is sqlite. You can start a mysql build using the following command: docker build --build-arg DB=mysql .

Here is a simple test setup:

docker run --name mysql --net <some-docker-network>\
 -e MYSQL_ROOT_PASSWORD=<my-secret-pw>\
 -e MYSQL_DATABASE=bitwarden\
 -e MYSQL_USER=<bitwarden_user>\
 -e MYSQL_PASSWORD=<bitwarden_pw> -d mysql:5.7

docker run -d --name bitwarden --net <some-docker-network>\
 -v $(pwd)/bw-data/:/data/ -v <Path to ssl certs>:/ssl/\
 -p 443:80 -e ROCKET_TLS='{certs="/ssl/<your ssl cert>",key="/ssl/<your ssl key>"}'\
 -e RUST_BACKTRACE=1 -e DATABASE_URL='mysql://<bitwarden_user>:<bitwarden_pw>@mysql/bitwarden'\
 -e ADMIN_TOKEN=<some_random_token_as_per_above_explanation>\
 -e ENABLE_DB_WAL='false' <you bitwarden image build above>

Current supported features

  • initial mysql and sqlite support
  • per backend schemas and migrations
  • Make backends (features) mutually exclusive
  • backward compatibility through migrations and sqlite defaults (needs testing)
  • Adapt Docker files for other archs

What still needs to be done apart from review and backward compatibility and migration testing:

  • once this is in, documentation on how to use the new backend in wiki

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/dani-garcia/vaultwarden/pull/493 **Author:** [@endyman](https://github.com/endyman) **Created:** 5/27/2019 **Status:** ✅ Merged **Merged:** 6/2/2019 **Merged by:** [@dani-garcia](https://github.com/dani-garcia) **Base:** `master` ← **Head:** `feature/initial_mysql_support` --- ### 📝 Commits (10+) - [`42af7c6`](https://github.com/dani-garcia/vaultwarden/commit/42af7c6dab113388a0db4fae0c196bae14761bc1) MySQL database - [`85c8a01`](https://github.com/dani-garcia/vaultwarden/commit/85c8a01f4a0f51efb2432396743878477529b72f) Merge branch 'master' of github.com:Skeen/bitwarden_rs - [`ab95a69`](https://github.com/dani-garcia/vaultwarden/commit/ab95a69dc8be20401bcc3167c51fb5f8b99ed2a2) Rework migrations for MySQL - [`e22e290`](https://github.com/dani-garcia/vaultwarden/commit/e22e290f677c01354446bf784287114696f2eeaa) Fix key and type variable names for mysql - [`233b48b`](https://github.com/dani-garcia/vaultwarden/commit/233b48bdad8d5c9571831a40dd8b7d6cb0e6f280) Fix missing joinable in schema - [`eb9d5e1`](https://github.com/dani-garcia/vaultwarden/commit/eb9d5e1196840a45a11329e46911c1db7ce7a496) Reintroduce .env.template - [`5fb6531`](https://github.com/dani-garcia/vaultwarden/commit/5fb6531db869ae395f1ac08695023d0dd27879d0) Attempt to fix azure pipeline - [`6f78395`](https://github.com/dani-garcia/vaultwarden/commit/6f78395ef71bd037fff24aeb60318c109294971a) Passwordless sudo on azure? - [`badd22a`](https://github.com/dani-garcia/vaultwarden/commit/badd22ac3d1b6c364c7be59e64ec0c48f2b960dd) Make docker image build - [`ff75939`](https://github.com/dani-garcia/vaultwarden/commit/ff759397f6742781a722dab029d695c4bbcf794a) initial mysql support ### 📊 Changes **75 files changed** (+610 additions, -134 deletions) <details> <summary>View changed files</summary> 📝 `.travis.yml` (+3 -1) 📝 `Cargo.lock` (+12 -13) 📝 `Cargo.toml` (+6 -4) 📝 `Dockerfile` (+12 -2) 📝 `Dockerfile.aarch64` (+7 -2) 📝 `Dockerfile.alpine` (+15 -2) 📝 `Dockerfile.armv6` (+7 -2) 📝 `Dockerfile.armv7` (+8 -2) 📝 `azure-pipelines.yml` (+10 -2) 📝 `migrations/mysql/2018-01-14-171611_create_tables/down.sql` (+0 -0) ➕ `migrations/mysql/2018-01-14-171611_create_tables/up.sql` (+62 -0) 📝 `migrations/mysql/2018-02-17-205753_create_collections_and_orgs/down.sql` (+0 -0) ➕ `migrations/mysql/2018-02-17-205753_create_collections_and_orgs/up.sql` (+30 -0) 📝 `migrations/mysql/2018-04-27-155151_create_users_ciphers/down.sql` (+0 -0) ➕ `migrations/mysql/2018-04-27-155151_create_users_ciphers/up.sql` (+34 -0) 📝 `migrations/mysql/2018-05-08-161616_create_collection_cipher_map/down.sql` (+0 -0) ➕ `migrations/mysql/2018-05-08-161616_create_collection_cipher_map/up.sql` (+5 -0) 📝 `migrations/mysql/2018-05-25-232323_update_attachments_reference/down.sql` (+0 -0) ➕ `migrations/mysql/2018-05-25-232323_update_attachments_reference/up.sql` (+14 -0) 📝 `migrations/mysql/2018-06-01-112529_update_devices_twofactor_remember/down.sql` (+0 -0) _...and 55 more files_ </details> ### 📄 Description This is a merged PR based on the work of @skeen in #486 and our efforts to support additional backends. Using build args the desired backend can be selected, the default is sqlite. You can start a mysql build using the following command: `docker build --build-arg DB=mysql .` Here is a simple test setup: ``` docker run --name mysql --net <some-docker-network>\ -e MYSQL_ROOT_PASSWORD=<my-secret-pw>\ -e MYSQL_DATABASE=bitwarden\ -e MYSQL_USER=<bitwarden_user>\ -e MYSQL_PASSWORD=<bitwarden_pw> -d mysql:5.7 docker run -d --name bitwarden --net <some-docker-network>\ -v $(pwd)/bw-data/:/data/ -v <Path to ssl certs>:/ssl/\ -p 443:80 -e ROCKET_TLS='{certs="/ssl/<your ssl cert>",key="/ssl/<your ssl key>"}'\ -e RUST_BACKTRACE=1 -e DATABASE_URL='mysql://<bitwarden_user>:<bitwarden_pw>@mysql/bitwarden'\ -e ADMIN_TOKEN=<some_random_token_as_per_above_explanation>\ -e ENABLE_DB_WAL='false' <you bitwarden image build above> ``` Current supported features - [x] initial mysql and sqlite support - [x] per backend schemas and migrations - [x] Make backends (features) mutually exclusive - [x] backward compatibility through migrations and sqlite defaults (needs testing) - [x] Adapt Docker files for other archs What still needs to be done apart from review and backward compatibility and migration testing: - once this is in, documentation on how to use the new backend in wiki --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2025-10-09 18:28:25 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#3701