pub struct MigrationsBuilder<'u> { /* private fields */ }
Available on crate feature from-directory only.
Expand description

Allows to build a Vec<M<'u>> with additional edits.

Implementations§

source§

impl<'u> MigrationsBuilder<'u>

source

pub fn from_directory(dir: &'static Dir<'static>) -> Result<Self>

Creates a set of migrations from a given directory by scanning subdirectories with a specified name pattern. The migrations are loaded and stored in the binary.

See the crate::Migrations::from_directory method for additional information regarding the directory structure.

§Example
use rusqlite_migration::{Migrations, MigrationsBuilder};
use include_dir::{Dir, include_dir};

static MIGRATION_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/../examples/from-directory/migrations");
let migrations: Migrations = MigrationsBuilder::from_directory(&MIGRATION_DIR).unwrap().finalize();
§Errors

Returns crate::Error::FileLoad in case the subdirectory names are incorrect, or don’t contain at least a valid up.sql file.

source

pub fn edit(self, id: usize, f: impl Fn(M<'_>) -> M<'_>) -> Self

Allows to edit a migration with a given id.

§Panics

Panics if no migration with the id provided exists.

source

pub fn finalize<T: FromIterator<M<'u>>>(self) -> T

Finalizes the builder and creates either a crate::Migrations or a crate::AsyncMigrations instance.

Trait Implementations§

source§

impl<'u> Debug for MigrationsBuilder<'u>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'u> Default for MigrationsBuilder<'u>

source§

fn default() -> MigrationsBuilder<'u>

Returns the “default value” for a type. Read more
source§

impl<'u> FromIterator<M<'u>> for MigrationsBuilder<'u>

source§

fn from_iter<T: IntoIterator<Item = M<'u>>>(iter: T) -> Self

Creates a value from an iterator. Read more

Auto Trait Implementations§

§

impl<'u> Freeze for MigrationsBuilder<'u>

§

impl<'u> !RefUnwindSafe for MigrationsBuilder<'u>

§

impl<'u> Send for MigrationsBuilder<'u>

§

impl<'u> Sync for MigrationsBuilder<'u>

§

impl<'u> Unpin for MigrationsBuilder<'u>

§

impl<'u> !UnwindSafe for MigrationsBuilder<'u>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.