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

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

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

Create a new EmbeddedMigration with the given tag

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

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

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

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Define functionality that runs for up migrations

Define functionality that runs for down migrations

A unique identifying tag

Option migration description. Defaults to Migratable::tag

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.