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: String
up: 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
Define functionality that runs for up
migrations
Define functionality that runs for down
migrations
Option migration description. Defaults to Migratable::tag
Auto Trait Implementations
impl RefUnwindSafe for EmbeddedMigration
impl Send for EmbeddedMigration
impl Sync for EmbeddedMigration
impl Unpin for EmbeddedMigration
impl UnwindSafe for EmbeddedMigration
Blanket Implementations
Mutably borrows from an owned value. Read more