diff options
author | Daniel García <[email protected]> | 2020-08-18 17:15:44 +0200 |
---|---|---|
committer | Daniel García <[email protected]> | 2020-08-24 20:11:17 +0200 |
commit | 0365b7c6a4d8aa88fd9328fcc14beef300fe33a2 (patch) | |
tree | b58aec0e0e57a422b95227538faeefb30f92e288 /build.rs | |
parent | 19889187a5d3f48cbe5ad7ec3a0c4d0bcdb7b894 (diff) | |
download | vaultwarden-0365b7c6a4d8aa88fd9328fcc14beef300fe33a2.tar.gz vaultwarden-0365b7c6a4d8aa88fd9328fcc14beef300fe33a2.zip |
Add support for multiple simultaneous database features by using macros.
Diesel requires the following changes:
- Separate connection and pool types per connection, the generate_connections! macro generates an enum with a variant per db type
- Separate migrations and schemas, these were always imported as one type depending on db feature, now they are all imported under different module names
- Separate model objects per connection, the db_object! macro generates one object for each connection with the diesel macros, a generic object, and methods to convert between the connection-specific and the generic ones
- Separate connection queries, the db_run! macro allows writing only one that gets compiled for all databases or multiple ones
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -1,13 +1,14 @@ use std::process::Command; use std::env; -fn main() { - #[cfg(all(feature = "sqlite", feature = "mysql"))] - compile_error!("Can't enable both sqlite and mysql at the same time"); - #[cfg(all(feature = "sqlite", feature = "postgresql"))] - compile_error!("Can't enable both sqlite and postgresql at the same time"); - #[cfg(all(feature = "mysql", feature = "postgresql"))] - compile_error!("Can't enable both mysql and postgresql at the same time"); +fn main() { + // This allow using #[cfg(sqlite)] instead of #[cfg(feature = "sqlite")], which helps when trying to add them through macros + #[cfg(feature = "sqlite")] + println!("cargo:rustc-cfg=sqlite"); + #[cfg(feature = "mysql")] + println!("cargo:rustc-cfg=mysql"); + #[cfg(feature = "postgresql")] + println!("cargo:rustc-cfg=postgresql"); #[cfg(not(any(feature = "sqlite", feature = "mysql", feature = "postgresql")))] compile_error!("You need to enable one DB backend. To build with previous defaults do: cargo build --features sqlite"); |