Update to latest sqlx, config and uuid

This commit is contained in:
Luca P 2022-07-05 17:47:21 +01:00
parent 7e997e9a6c
commit a7ca2b06b5
4 changed files with 354 additions and 402 deletions

737
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -16,9 +16,9 @@ name = "zero2prod"
actix-web = "4"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
serde = "1.0.115"
config = { version = "0.11", default-features = false, features = ["yaml"] }
sqlx = { version = "0.5.5", default-features = false, features = ["runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] }
uuid = { version = "0.8.1", features = ["v4"] }
config = { version = "0.13", default-features = false, features = ["yaml"] }
sqlx = { version = "0.6", default-features = false, features = ["runtime-actix-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] }
uuid = { version = "1", features = ["v4"] }
chrono = "0.4.15"
[dev-dependencies]

View file

@ -10,7 +10,7 @@ fi
if ! [ -x "$(command -v sqlx)" ]; then
echo >&2 "Error: sqlx is not installed."
echo >&2 "Use:"
echo >&2 " cargo install --version=0.5.5 sqlx-cli --no-default-features --features postgres"
echo >&2 " cargo install --version=0.6.0 sqlx-cli --no-default-features --features postgres"
echo >&2 "to install it."
exit 1
fi
@ -19,7 +19,7 @@ fi
DB_USER="${POSTGRES_USER:=postgres}"
# Check if a custom password has been set, otherwise default to 'password'
DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
# Check if a custom password has been set, otherwise default to 'newsletter'
# Check if a custom database name has been set, otherwise default to 'newsletter'
DB_NAME="${POSTGRES_DB:=newsletter}"
# Check if a custom port has been set, otherwise default to '5432'
DB_PORT="${POSTGRES_PORT:=5432}"

View file

@ -30,9 +30,8 @@ impl DatabaseSettings {
}
pub fn get_configuration() -> Result<Settings, config::ConfigError> {
let mut settings = config::Config::default();
settings.merge(config::File::with_name("configuration"))?;
settings.try_into()
let settings = config::Config::builder()
.add_source(config::File::new("configuration.yaml", config::FileFormat::Yaml))
.build()?;
settings.try_deserialize::<Settings>()
}