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.
NOTE: There are just few items which cause some issues with models and schemas having the exact same name, and that causes some ambiguity. I have solved that currently by adding schema:: in-front of those specific items. But it would be nicer if we didn't need that though.
Not sure what the best way is to address this. Probably renaming the tables is the best option i think.
I still want to do some testing with the different database types with an empty database, an existing database which needs migrations etc.. etc..
Also, we probably want to wait until Diesel releases v2.1.1, since there are currently some bugs and missing features which got fixed, but not yet merged.
And if someone else wants to help test, please do!, The more the better.
🔄 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/3796
**Author:** [@BlackDex](https://github.com/BlackDex)
**Created:** 8/24/2023
**Status:** ❌ Closed
**Base:** `main` ← **Head:** `diesel-multiconnect`
---
### 📝 Commits (1)
- [`1b1596c`](https://github.com/dani-garcia/vaultwarden/commit/1b1596ce1e1534020a9a7735ae781504da48cda5) Use Diesels MultiConnections Derive
### 📊 Changes
**44 files changed** (+1908 additions, -2926 deletions)
<details>
<summary>View changed files</summary>
📝 `Cargo.lock` (+0 -11)
📝 `Cargo.toml` (+7 -3)
📝 `src/api/admin.rs` (+85 -79)
📝 `src/api/core/accounts.rs` (+82 -93)
📝 `src/api/core/ciphers.rs` (+133 -139)
📝 `src/api/core/emergency_access.rs` (+84 -88)
📝 `src/api/core/events.rs` (+18 -18)
📝 `src/api/core/folders.rs` (+15 -15)
📝 `src/api/core/mod.rs` (+2 -2)
📝 `src/api/core/organizations.rs` (+266 -307)
📝 `src/api/core/public.rs` (+19 -23)
📝 `src/api/core/sends.rs` (+60 -66)
📝 `src/api/core/two_factor/authenticator.rs` (+8 -8)
📝 `src/api/core/two_factor/duo.rs` (+10 -10)
📝 `src/api/core/two_factor/email.rs` (+16 -16)
📝 `src/api/core/two_factor/mod.rs` (+20 -20)
📝 `src/api/core/two_factor/webauthn.rs` (+24 -25)
📝 `src/api/core/two_factor/yubikey.rs` (+7 -7)
📝 `src/api/identity.rs` (+15 -26)
📝 `src/api/notifications.rs` (+5 -5)
_...and 24 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.
---
**NOTE:** There are just few items which cause some issues with models and schemas having the exact same name, and that causes some ambiguity. I have solved that currently by adding `schema::` in-front of those specific items. But it would be nicer if we didn't need that though.
Not sure what the best way is to address this. Probably renaming the tables is the best option i think.
I still want to do some testing with the different database types with an empty database, an existing database which needs migrations etc.. etc..
Also, we probably want to wait until Diesel releases v2.1.1, since there are currently some bugs and missing features which got fixed, but not yet merged.
And if someone else wants to help test, please do!, The more the better.
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/dani-garcia/vaultwarden/pull/3796
Author: @BlackDex
Created: 8/24/2023
Status: ❌ Closed
Base:
main← Head:diesel-multiconnect📝 Commits (1)
1b1596cUse Diesels MultiConnections Derive📊 Changes
44 files changed (+1908 additions, -2926 deletions)
View changed files
📝
Cargo.lock(+0 -11)📝
Cargo.toml(+7 -3)📝
src/api/admin.rs(+85 -79)📝
src/api/core/accounts.rs(+82 -93)📝
src/api/core/ciphers.rs(+133 -139)📝
src/api/core/emergency_access.rs(+84 -88)📝
src/api/core/events.rs(+18 -18)📝
src/api/core/folders.rs(+15 -15)📝
src/api/core/mod.rs(+2 -2)📝
src/api/core/organizations.rs(+266 -307)📝
src/api/core/public.rs(+19 -23)📝
src/api/core/sends.rs(+60 -66)📝
src/api/core/two_factor/authenticator.rs(+8 -8)📝
src/api/core/two_factor/duo.rs(+10 -10)📝
src/api/core/two_factor/email.rs(+16 -16)📝
src/api/core/two_factor/mod.rs(+20 -20)📝
src/api/core/two_factor/webauthn.rs(+24 -25)📝
src/api/core/two_factor/yubikey.rs(+7 -7)📝
src/api/identity.rs(+15 -26)📝
src/api/notifications.rs(+5 -5)...and 24 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.
NOTE: There are just few items which cause some issues with models and schemas having the exact same name, and that causes some ambiguity. I have solved that currently by adding
schema::in-front of those specific items. But it would be nicer if we didn't need that though.Not sure what the best way is to address this. Probably renaming the tables is the best option i think.
I still want to do some testing with the different database types with an empty database, an existing database which needs migrations etc.. etc..
Also, we probably want to wait until Diesel releases v2.1.1, since there are currently some bugs and missing features which got fixed, but not yet merged.
And if someone else wants to help test, please do!, The more the better.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.