awidegreen / vmail-rs

Command line mailbox account management tool for vmail (MySQL)
BSD 3-Clause "New" or "Revised" License
18 stars 2 forks source link

Make it easier to switch to another database backend #6

Closed burrscurr closed 4 years ago

burrscurr commented 4 years ago

Hi! I personally use a mail server setup created from Thomas Leistner's tutorial and am very happy with it. I use a postgres database instead of a mysql one.

To make it possible to use this management tool, I made some changes that help to switch to another database backend like postgres. Now, the database backend is specified in a single line and can be switched more easily.

I'm pretty new to rust, so I hope my changes are fine. This PR should not change the behaviour of vmail-lib.

awidegreen commented 4 years ago

Thank you.

Are you planning to take the changes a step further and add Postgres support to vmail?

burrscurr commented 4 years ago

I think it would be nice to support postgres. Currently, one has to change the cargo file and two lines in the code to use a postgres database.

I see these options:

I like the second, and even more, the third approach. Unfortunately, I don't know how exactly build options could be implemented, and for the implicit env-file option I'm not really sure if it is possible in rust to set the type of the database connection in runtime.

In general, I enjoy working with rust very much, so I'd be happy to add postgres support and learn more about the language.

burrscurr commented 4 years ago

Well, build options were documented well enough, so I created a PR for the second option implementing just this.