cargo-sqlx: update SQLx to v0.3

This commit is contained in:
Ryan Leckey
2020-04-07 15:55:06 -07:00
parent 012c186069
commit 466b6d6bed
3 changed files with 11 additions and 18 deletions

2
Cargo.lock generated
View File

@@ -294,7 +294,7 @@ dependencies = [
"chrono",
"dotenv",
"futures 0.3.4",
"sqlx 0.2.6",
"sqlx",
"structopt",
"tokio 0.2.13",
]

View File

@@ -16,11 +16,8 @@ path = "src/main.rs"
[dependencies]
dotenv = "0.15"
tokio = { version = "0.2", features = ["macros"] }
# sqlx = { path = "..", default-features = false, features = [ "runtime-tokio", "macros", "postgres" ] }
sqlx = { version = "0.2", default-features = false, features = [ "runtime-tokio", "macros", "postgres" ] }
futures="0.3"
sqlx = { version = "0.3", path = "..", default-features = false, features = [ "runtime-tokio", "postgres" ] }
futures = "0.3"
structopt = "0.3"
chrono = "0.4"

View File

@@ -182,19 +182,15 @@ CREATE TABLE IF NOT EXISTS __migrations (
}
async fn check_if_applied(pool: &mut PgConnection, migration: &str) -> bool {
use sqlx::row::Row;
use sqlx::postgres::PgRow;
use sqlx::Row;
let row = sqlx::query(
"select exists(select migration from __migrations where migration = $1) as exists",
)
.bind(migration.to_string())
.fetch_one(pool)
.await
.expect("Failed to check migration table");
let exists: bool = row.get("exists");
exists
sqlx::query("select exists(select migration from __migrations where migration = $1) as exists")
.bind(migration.to_string())
.try_map(|row: PgRow| row.try_get("exists"))
.fetch_one(pool)
.await
.expect("Failed to check migration table")
}
async fn save_applied_migration(pool: &mut PgConnection, migration: &str) {