Upgrade uuid, sqlx and config

This commit is contained in:
Luca P 2022-07-05 17:47:21 +01:00
parent f2103c2720
commit e82f0c656c
4 changed files with 383 additions and 423 deletions

787
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"
tracing = "0.1.19"
tracing-subscriber = { version = "0.3", features = ["registry", "env-filter"] }

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

@ -39,9 +39,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>()
}