mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2025-02-19 20:16:19 +00:00
Update sqlx to 0.7
This commit is contained in:
parent
c706a54aaa
commit
2b8a8244d7
8 changed files with 883 additions and 613 deletions
4
.github/workflows/general.yml
vendored
4
.github/workflows/general.yml
vendored
|
@ -14,7 +14,7 @@ on:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
SQLX_VERSION: 0.6.2
|
SQLX_VERSION: 0.7.1
|
||||||
SQLX_FEATURES: "rustls,postgres"
|
SQLX_FEATURES: "rustls,postgres"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
@ -49,7 +49,7 @@ jobs:
|
||||||
SKIP_DOCKER=true ./scripts/init_db.sh
|
SKIP_DOCKER=true ./scripts/init_db.sh
|
||||||
- name: Check sqlx-data.json is up-to-date
|
- name: Check sqlx-data.json is up-to-date
|
||||||
run: |
|
run: |
|
||||||
cargo sqlx prepare --check -- --bin zero2prod
|
cargo sqlx prepare --workspace --check
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cargo test
|
run: cargo test
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "\n INSERT INTO subscriptions (id, email, name, subscribed_at)\n VALUES ($1, $2, $3, $4)\n ",
|
||||||
|
"describe": {
|
||||||
|
"columns": [],
|
||||||
|
"parameters": {
|
||||||
|
"Left": [
|
||||||
|
"Uuid",
|
||||||
|
"Text",
|
||||||
|
"Text",
|
||||||
|
"Timestamptz"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nullable": []
|
||||||
|
},
|
||||||
|
"hash": "793f0df728d217c204123f12e4eafd6439db2d49d0cb506618ae9e780c7e0558"
|
||||||
|
}
|
1447
Cargo.lock
generated
1447
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -17,7 +17,7 @@ actix-web = "4"
|
||||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||||
serde = "1.0.115"
|
serde = "1.0.115"
|
||||||
config = { version = "0.13", default-features = false, features = ["yaml"] }
|
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", "offline"] }
|
sqlx = { version = "0.7", default-features = false, features = ["runtime-tokio-rustls", "macros", "postgres", "uuid", "chrono", "migrate"] }
|
||||||
uuid = { version = "1", features = ["v4"] }
|
uuid = { version = "1", features = ["v4"] }
|
||||||
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
|
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -10,7 +10,7 @@ fi
|
||||||
if ! [ -x "$(command -v sqlx)" ]; then
|
if ! [ -x "$(command -v sqlx)" ]; then
|
||||||
echo >&2 "Error: sqlx is not installed."
|
echo >&2 "Error: sqlx is not installed."
|
||||||
echo >&2 "Use:"
|
echo >&2 "Use:"
|
||||||
echo >&2 " cargo install --version='~0.6' sqlx-cli --no-default-features --features rustls,postgres"
|
echo >&2 " cargo install --version='~0.7' sqlx-cli --no-default-features --features rustls,postgres"
|
||||||
echo >&2 "to install it."
|
echo >&2 "to install it."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
{
|
|
||||||
"db": "PostgreSQL",
|
|
||||||
"793f0df728d217c204123f12e4eafd6439db2d49d0cb506618ae9e780c7e0558": {
|
|
||||||
"query": "\n INSERT INTO subscriptions (id, email, name, subscribed_at)\n VALUES ($1, $2, $3, $4)\n ",
|
|
||||||
"describe": {
|
|
||||||
"columns": [],
|
|
||||||
"parameters": {
|
|
||||||
"Left": [
|
|
||||||
"Uuid",
|
|
||||||
"Text",
|
|
||||||
"Text",
|
|
||||||
"Timestamptz"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"nullable": []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
use secrecy::{ExposeSecret, Secret};
|
use secrecy::{ExposeSecret, Secret};
|
||||||
use serde_aux::field_attributes::deserialize_number_from_string;
|
use serde_aux::field_attributes::deserialize_number_from_string;
|
||||||
use sqlx::postgres::{PgConnectOptions, PgSslMode};
|
use sqlx::postgres::{PgConnectOptions, PgSslMode};
|
||||||
use sqlx::ConnectOptions;
|
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
|
|
||||||
#[derive(serde::Deserialize)]
|
#[derive(serde::Deserialize)]
|
||||||
|
@ -44,9 +43,7 @@ impl DatabaseSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_db(&self) -> PgConnectOptions {
|
pub fn with_db(&self) -> PgConnectOptions {
|
||||||
let mut options = self.without_db().database(&self.database_name);
|
self.without_db().database(&self.database_name)
|
||||||
options.log_statements(tracing::log::LevelFilter::Trace);
|
|
||||||
options
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ async fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
let configuration = get_configuration().expect("Failed to read configuration.");
|
let configuration = get_configuration().expect("Failed to read configuration.");
|
||||||
let connection_pool = PgPoolOptions::new()
|
let connection_pool = PgPoolOptions::new()
|
||||||
.acquire_timeout(std::time::Duration::from_secs(2))
|
|
||||||
.connect_lazy_with(configuration.database.with_db());
|
.connect_lazy_with(configuration.database.with_db());
|
||||||
|
|
||||||
let address = format!(
|
let address = format!(
|
||||||
|
|
Loading…
Reference in a new issue