[PR #6279] Use Diesels MultiConnections Derive #2424

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

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/6279
Author: @BlackDex
Created: 9/8/2025
Status: 🔄 Open

Base: mainHead: 2025-diesel-multiconnect


📝 Commits (6)

  • 03aa7e5 Use Diesels MultiConnections Derive
  • e58d64f Adjust query_logger and some other small items
  • 02af16b Remove macro, replaced with an function
  • 7763042 Implement custom connection manager
  • 78c8fd3 Updated some crates to keep up2date
  • 65b119f Small adjustment

📊 Changes

61 files changed (+3069 additions, -4009 deletions)

View changed files

📝 .github/workflows/build.yml (+3 -19)
📝 .github/workflows/hadolint.yml (+1 -1)
📝 .github/workflows/release.yml (+4 -4)
📝 .github/workflows/trivy.yml (+2 -2)
📝 .github/workflows/zizmor.yml (+1 -1)
📝 Cargo.lock (+468 -462)
📝 Cargo.toml (+19 -21)
📝 build.rs (+0 -6)
📝 docker/Dockerfile.alpine (+3 -3)
📝 docker/Dockerfile.j2 (+3 -3)
📝 macros/Cargo.toml (+1 -1)
📝 src/api/admin.rs (+99 -90)
📝 src/api/core/accounts.rs (+128 -128)
📝 src/api/core/ciphers.rs (+162 -183)
📝 src/api/core/emergency_access.rs (+89 -83)
📝 src/api/core/events.rs (+18 -23)
📝 src/api/core/folders.rs (+19 -16)
📝 src/api/core/mod.rs (+8 -10)
📝 src/api/core/organizations.rs (+327 -348)
📝 src/api/core/public.rs (+28 -25)

...and 41 more files

📄 Description

With this PR we remove almost all custom macro's to create the multiple database type code. This is now handled by Diesel it self.

This removed the need of the following functions/macro's:

  • db_object!
  • ::to_db
  • .from_db()

It is also possible to just use one schema instead of multiple per type.

Also done:

  • Refactored the SQLite backup function
  • Some formatting of queries so every call is one a separate line, this looks a bit better
  • Declare conn as mut inside each db_run! instead of having to declare it as mut in functions or calls
  • Added an ACTIVE_DB_TYPE static which holds the currently active database type
  • Removed diesel_logger crate and use Diesel's set_default_instrumentation()
    If you want debug queries you can now simply change the log level of vaultwarden::db::query_logger
  • Use PostgreSQL v17 in the Alpine images to match the Debian Trixie version
  • Optimized the Workflows since diesel_logger isn't needed anymore

And on the extra plus-side, this lowers the compile-time and binary size too.


🔄 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/6279 **Author:** [@BlackDex](https://github.com/BlackDex) **Created:** 9/8/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `2025-diesel-multiconnect` --- ### 📝 Commits (6) - [`03aa7e5`](https://github.com/dani-garcia/vaultwarden/commit/03aa7e5090966835a35050b44b403f3887fb035a) Use Diesels MultiConnections Derive - [`e58d64f`](https://github.com/dani-garcia/vaultwarden/commit/e58d64fc004d67a9306ea29166465fa00ac7caef) Adjust query_logger and some other small items - [`02af16b`](https://github.com/dani-garcia/vaultwarden/commit/02af16bb080e833a87ccb663b8959a2a80869706) Remove macro, replaced with an function - [`7763042`](https://github.com/dani-garcia/vaultwarden/commit/776304268b5b6f1fcf010c975e343c7c296b5883) Implement custom connection manager - [`78c8fd3`](https://github.com/dani-garcia/vaultwarden/commit/78c8fd32d54d348365c40a1c79893b891a9d1263) Updated some crates to keep up2date - [`65b119f`](https://github.com/dani-garcia/vaultwarden/commit/65b119f1788244557877ce652a40d2d112ca842c) Small adjustment ### 📊 Changes **61 files changed** (+3069 additions, -4009 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/build.yml` (+3 -19) 📝 `.github/workflows/hadolint.yml` (+1 -1) 📝 `.github/workflows/release.yml` (+4 -4) 📝 `.github/workflows/trivy.yml` (+2 -2) 📝 `.github/workflows/zizmor.yml` (+1 -1) 📝 `Cargo.lock` (+468 -462) 📝 `Cargo.toml` (+19 -21) 📝 `build.rs` (+0 -6) 📝 `docker/Dockerfile.alpine` (+3 -3) 📝 `docker/Dockerfile.j2` (+3 -3) 📝 `macros/Cargo.toml` (+1 -1) 📝 `src/api/admin.rs` (+99 -90) 📝 `src/api/core/accounts.rs` (+128 -128) 📝 `src/api/core/ciphers.rs` (+162 -183) 📝 `src/api/core/emergency_access.rs` (+89 -83) 📝 `src/api/core/events.rs` (+18 -23) 📝 `src/api/core/folders.rs` (+19 -16) 📝 `src/api/core/mod.rs` (+8 -10) 📝 `src/api/core/organizations.rs` (+327 -348) 📝 `src/api/core/public.rs` (+28 -25) _...and 41 more files_ </details> ### 📄 Description With this PR we remove almost all custom macro's to create the multiple database type code. This is now handled by Diesel it self. This removed the need of the following functions/macro's: - `db_object!` - `::to_db` - `.from_db()` It is also possible to just use one schema instead of multiple per type. Also done: - Refactored the SQLite backup function - Some formatting of queries so every call is one a separate line, this looks a bit better - Declare `conn` as mut inside each `db_run!` instead of having to declare it as `mut` in functions or calls - Added an `ACTIVE_DB_TYPE` static which holds the currently active database type - Removed `diesel_logger` crate and use Diesel's `set_default_instrumentation()` If you want debug queries you can now simply change the log level of `vaultwarden::db::query_logger` - Use PostgreSQL v17 in the Alpine images to match the Debian Trixie version - Optimized the Workflows since `diesel_logger` isn't needed anymore And on the extra plus-side, this lowers the compile-time and binary size too. --- <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:04:55 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/vaultwarden#2424