Use Diesels MultiConnections Derive #1491

Closed
opened 2026-04-06 01:58:51 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @BlackDex on 8/24/2023

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.

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

No dependencies set.

Reference: github/vaultwarden#1491