Struct migrant_lib::migration::EmbeddedMigration[][src]

pub struct EmbeddedMigration {
    pub tag: String,
    pub up: Option<Cow<'static, str>>,
    pub down: Option<Cow<'static, str>>,
}

Define an embedded migration

SQL statements provided to EmbeddedMigration will be embedded in the executable so no files are required at run-time. The standard include_str! macro can be used to embed contents of files, or a string literal can be provided.

Note: SQL statements are batch executed as is. If you want your migration to happen atomically in a transaction you should manually wrap your statements in a transaction (begin transaction; ... commit;).

Database specific features (d-postgres/d-sqlite/d-mysql) are required to use this functionality.

Example

EmbeddedMigration::with_tag("create-users-table")
    .up(include_str!("../migrations/embedded/create_users_table/up.sql"))
    .down(include_str!("../migrations/embedded/create_users_table/down.sql"));
EmbeddedMigration::with_tag("create-places-table")
    .up("create table places(id integer);")
    .down("drop table places;");

Fields

tag: Stringup: Option<Cow<'static, str>>down: Option<Cow<'static, str>>

Implementations

impl EmbeddedMigration[src]

pub fn with_tag(_tag: &str) -> DatabaseFeatureRequired[src]

Create a new EmbeddedMigration with the given tag

pub fn up<T: Into<Cow<'static, str>>>(&mut self, stmt: T) -> &mut Self[src]

&'static str or String of statements to use for up migrations

pub fn down<T: Into<Cow<'static, str>>>(&mut self, stmt: T) -> &mut Self[src]

&'static str or String of statements to use for down migrations

pub fn boxed(&self) -> Box<dyn Migratable>[src]

Box this migration up so it can be stored with other migrations

Trait Implementations

impl Clone for EmbeddedMigration[src]

impl Debug for EmbeddedMigration[src]

impl Migratable for EmbeddedMigration[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.