pub struct SqliteMigrator { /* private fields */ }sqlite only.Expand description
Applies and validates River’s SQLite migration history.
Implementations§
Source§impl SqliteMigrator
impl SqliteMigrator
Sourcepub const fn new(pool: SqlitePool) -> Self
pub const fn new(pool: SqlitePool) -> Self
Creates a migrator for a SQLite pool.
Sourcepub fn all_versions() -> &'static [Migration]
pub fn all_versions() -> &'static [Migration]
Returns every SQLite migration bundled with this crate.
Sourcepub async fn existing_versions(&self) -> Result<Vec<i64>, Error>
pub async fn existing_versions(&self) -> Result<Vec<i64>, Error>
Returns applied main-line versions in ascending order.
§Errors
Returns Error::Database when the query fails.
Sourcepub async fn migrate(
&self,
direction: Direction,
opts: MigrateOpts,
) -> Result<MigrateResult, Error>
pub async fn migrate( &self, direction: Direction, opts: MigrateOpts, ) -> Result<MigrateResult, Error>
Applies up or down migrations with target, step, and dry-run controls.
Each migration runs in its own transaction, so a failure leaves the migrations before it applied.
§Errors
Returns Error::UnknownVersion when the target version doesn’t exist,
Error::TargetNotSelected when a down target isn’t applied or is
beyond the step limit, Error::OtherMigrationLines when reverting
version 5 would lose other migration lines’ records, and Error::Database when a migration fails.
§Cancel safety
Each migration and its record in river_migration commit together in
their own transaction, on a task of their own. Dropping the future
stops migrating once the migration in progress finishes: it and
every migration before it stay applied, and migrating again
continues from there.
Sourcepub async fn migrate_up(&self) -> Result<Vec<i64>, Error>
pub async fn migrate_up(&self) -> Result<Vec<i64>, Error>
Applies all outstanding up migrations and returns their versions.
§Errors
Returns Error::Database when a migration fails.
§Cancel safety
Each migration and its record in river_migration commit together in
their own transaction, on a task of their own. Dropping the future
stops migrating once the migration in progress finishes: it and
every migration before it stay applied, and migrating again
continues from there.
Sourcepub async fn validate(
&self,
target_version: Option<i64>,
) -> Result<ValidateResult, Error>
pub async fn validate( &self, target_version: Option<i64>, ) -> Result<ValidateResult, Error>
Checks that every migration through an optional target is applied.
§Errors
Returns Error::UnknownVersion when the target version doesn’t exist and
Error::Database when reading the applied versions fails.
Trait Implementations§
Source§impl Clone for SqliteMigrator
impl Clone for SqliteMigrator
Auto Trait Implementations§
impl !RefUnwindSafe for SqliteMigrator
impl !UnwindSafe for SqliteMigrator
impl Freeze for SqliteMigrator
impl Send for SqliteMigrator
impl Sync for SqliteMigrator
impl Unpin for SqliteMigrator
impl UnsafeUnpin for SqliteMigrator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more