pub struct PostgresMigrator { /* private fields */ }postgres only.Expand description
Applies and validates River’s PostgreSQL migration history.
Implementations§
Source§impl PostgresMigrator
impl PostgresMigrator
Sourcepub fn all_versions() -> &'static [Migration]
pub fn all_versions() -> &'static [Migration]
Returns every migration bundled with this crate.
Sourcepub fn with_schema(self, schema: SchemaName) -> Self
pub fn with_schema(self, schema: SchemaName) -> Self
Returns the migrator with schema migrated instead of the
connection’s current schema.
Sourcepub const fn schema(&self) -> &SchemaName
pub const fn schema(&self) -> &SchemaName
Returns the schema this migrator migrates.
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_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 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, 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 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 PostgresMigrator
impl Clone for PostgresMigrator
Auto Trait Implementations§
impl !RefUnwindSafe for PostgresMigrator
impl !UnwindSafe for PostgresMigrator
impl Freeze for PostgresMigrator
impl Send for PostgresMigrator
impl Sync for PostgresMigrator
impl Unpin for PostgresMigrator
impl UnsafeUnpin for PostgresMigrator
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