[PR #6279] [MERGED] Use Diesels MultiConnections Derive #25968

Closed
opened 2026-05-29 04:56:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dani-garcia/vaultwarden/pull/6279
Author: @BlackDex
Created: 9/8/2025
Status: Merged
Merged: 10/29/2025
Merged by: @dani-garcia

Base: mainHead: 2025-diesel-multiconnect


📝 Commits (8)

  • 6e8af1b Use Diesels MultiConnections Derive
  • 666d6ce Adjust query_logger and some other small items
  • 522de62 Remove macro, replaced with an function
  • fd03d78 Implement custom connection manager
  • bf559fd Updated some crates to keep up2date
  • 9afad72 Small adjustment
  • 4911484 crate updates
  • d3c8d04 Update crates

📊 Changes

61 files changed (+3219 additions, -4213 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 (+605 -652)
📝 Cargo.toml (+30 -32)
📝 build.rs (+0 -6)
📝 docker/Dockerfile.alpine (+3 -3)
📝 docker/Dockerfile.j2 (+3 -3)
📝 macros/Cargo.toml (+2 -2)
📝 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:** ✅ Merged **Merged:** 10/29/2025 **Merged by:** [@dani-garcia](https://github.com/dani-garcia) **Base:** `main` ← **Head:** `2025-diesel-multiconnect` --- ### 📝 Commits (8) - [`6e8af1b`](https://github.com/dani-garcia/vaultwarden/commit/6e8af1b8a763e5de45b23694f29e0cd1018f04e1) Use Diesels MultiConnections Derive - [`666d6ce`](https://github.com/dani-garcia/vaultwarden/commit/666d6ce968e14e7aa2a1a02faf7aa741710be5ca) Adjust query_logger and some other small items - [`522de62`](https://github.com/dani-garcia/vaultwarden/commit/522de62efbc36f3fb2d7f3bd070f51a57121a0d6) Remove macro, replaced with an function - [`fd03d78`](https://github.com/dani-garcia/vaultwarden/commit/fd03d78f15ba09b57b4ae33b09eea77018e5ca29) Implement custom connection manager - [`bf559fd`](https://github.com/dani-garcia/vaultwarden/commit/bf559fd6cbc6ab11123152eb14ff21d6303ab59e) Updated some crates to keep up2date - [`9afad72`](https://github.com/dani-garcia/vaultwarden/commit/9afad72f25f496f6c2f32c2780a8b340a4833068) Small adjustment - [`4911484`](https://github.com/dani-garcia/vaultwarden/commit/4911484865f4cf72c41fea6c323e63b20a7f4516) crate updates - [`d3c8d04`](https://github.com/dani-garcia/vaultwarden/commit/d3c8d04f2677379752085f42f8aa57e0eb2ddb47) Update crates ### 📊 Changes **61 files changed** (+3219 additions, -4213 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` (+605 -652) 📝 `Cargo.toml` (+30 -32) 📝 `build.rs` (+0 -6) 📝 `docker/Dockerfile.alpine` (+3 -3) 📝 `docker/Dockerfile.j2` (+3 -3) 📝 `macros/Cargo.toml` (+2 -2) 📝 `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>
GiteaMirror added the pull-request label 2026-05-29 04:56:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vaultwarden#25968