mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-04-10 12:16:30 +00:00
fix: bring back accidentally removed methods on the Migrate trait as deprecated
This commit is contained in:
@@ -107,6 +107,19 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
|
||||
})
|
||||
}
|
||||
|
||||
fn version(&mut self) -> BoxFuture<'_, Result<Option<(i64, bool)>, MigrateError>> {
|
||||
Box::pin(async move {
|
||||
// language=SQL
|
||||
let row = query_as(
|
||||
"SELECT version, NOT success FROM _sqlx_migrations ORDER BY version DESC LIMIT 1",
|
||||
)
|
||||
.fetch_optional(self)
|
||||
.await?;
|
||||
|
||||
Ok(row)
|
||||
})
|
||||
}
|
||||
|
||||
fn dirty_version(&mut self) -> BoxFuture<'_, Result<Option<i64>, MigrateError>> {
|
||||
Box::pin(async move {
|
||||
// language=SQL
|
||||
@@ -178,6 +191,30 @@ CREATE TABLE IF NOT EXISTS _sqlx_migrations (
|
||||
})
|
||||
}
|
||||
|
||||
fn validate<'e: 'm, 'm>(
|
||||
&'e mut self,
|
||||
migration: &'m Migration,
|
||||
) -> BoxFuture<'m, Result<(), MigrateError>> {
|
||||
Box::pin(async move {
|
||||
// language=SQL
|
||||
let checksum: Option<Vec<u8>> =
|
||||
query_scalar("SELECT checksum FROM _sqlx_migrations WHERE version = $1")
|
||||
.bind(migration.version)
|
||||
.fetch_optional(self)
|
||||
.await?;
|
||||
|
||||
if let Some(checksum) = checksum {
|
||||
return if checksum == &*migration.checksum {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(MigrateError::VersionMismatch(migration.version))
|
||||
};
|
||||
} else {
|
||||
Err(MigrateError::VersionMissing(migration.version))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn apply<'e: 'm, 'm>(
|
||||
&'e mut self,
|
||||
migration: &'m Migration,
|
||||
|
||||
Reference in New Issue
Block a user