pub struct Builder { /* private fields */ }Expand description
Per-app migration runner config. Lets two rustango apps live in
the same Postgres database without colliding on the default
__rustango_migrations__ ledger table — each app picks its own
ledger name and the runners stay independent.
All verbs are mirrored on the Builder so a custom-ledger app
has the same surface as the default free functions:
let mine = Builder::default().ledger("__myapp_migrations__");
mine.migrate(&pool, dir).await?;
mine.applied_set(&pool).await?;Ledger names must be valid SQL identifiers ([A-Za-z_][A-Za-z0-9_]*,
≤ 63 bytes). .ledger("…") panics if not — this is a programming
error caught at config time, not a runtime input.
Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new() -> Self
pub fn new() -> Self
Equivalent to Builder::default(). Provided for symmetry with
the rest of the workspace’s builder constructors.
Sourcepub fn ledger(self, name: &'static str) -> Self
pub fn ledger(self, name: &'static str) -> Self
Override the ledger table name. Must be a valid SQL
identifier ([A-Za-z_][A-Za-z0-9_]*, ≤ 63 bytes).
§Panics
Panics if name isn’t a valid SQL identifier — the ledger
name is interpolated into DDL (CREATE TABLE, INSERT INTO,
SELECT FROM) so we refuse anything that could escape
quoting.
Sourcepub fn ledger_name(&self) -> &'static str
pub fn ledger_name(&self) -> &'static str
The configured ledger table name.
Sourcepub async fn migrate(
&self,
pool: &PgPool,
dir: &Path,
) -> Result<Vec<Migration>, MigrateError>
pub async fn migrate( &self, pool: &PgPool, dir: &Path, ) -> Result<Vec<Migration>, MigrateError>
Sourcepub async fn migrate_to(
&self,
pool: &PgPool,
dir: &Path,
target: &str,
) -> Result<Vec<Migration>, MigrateError>
pub async fn migrate_to( &self, pool: &PgPool, dir: &Path, target: &str, ) -> Result<Vec<Migration>, MigrateError>
Sourcepub async fn migrate_embedded(
&self,
pool: &PgPool,
embedded: &[(&str, &str)],
) -> Result<Vec<Migration>, MigrateError>
pub async fn migrate_embedded( &self, pool: &PgPool, embedded: &[(&str, &str)], ) -> Result<Vec<Migration>, MigrateError>
Sourcepub async fn migrate_dry_run(
&self,
pool: &PgPool,
dir: &Path,
) -> Result<Vec<MigrationPreview>, MigrateError>
pub async fn migrate_dry_run( &self, pool: &PgPool, dir: &Path, ) -> Result<Vec<MigrationPreview>, MigrateError>
Sourcepub async fn downgrade(
&self,
pool: &PgPool,
dir: &Path,
steps: usize,
) -> Result<Vec<Migration>, MigrateError>
pub async fn downgrade( &self, pool: &PgPool, dir: &Path, steps: usize, ) -> Result<Vec<Migration>, MigrateError>
Sourcepub async fn unapply(
&self,
pool: &PgPool,
dir: &Path,
name: &str,
) -> Result<Migration, MigrateError>
pub async fn unapply( &self, pool: &PgPool, dir: &Path, name: &str, ) -> Result<Migration, MigrateError>
Sourcepub async fn unapply_force(
&self,
pool: &PgPool,
dir: &Path,
name: &str,
) -> Result<Migration, MigrateError>
pub async fn unapply_force( &self, pool: &PgPool, dir: &Path, name: &str, ) -> Result<Migration, MigrateError>
Sourcepub async fn applied_set(
&self,
pool: &PgPool,
) -> Result<HashSet<String>, MigrateError>
pub async fn applied_set( &self, pool: &PgPool, ) -> Result<HashSet<String>, MigrateError>
Sourcepub async fn ensure_ledger(&self, pool: &PgPool) -> Result<(), MigrateError>
pub async fn ensure_ledger(&self, pool: &PgPool) -> Result<(), MigrateError>
Trait Implementations§
impl Copy for Builder
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
impl UnwindSafe for Builder
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