Use Diesels MultiConnections Derive #359

Closed
opened 2026-04-05 21:00:34 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @BlackDex on 9/8/2025

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.

*Originally created by @BlackDex on 9/8/2025* 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.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/vaultwarden#359