Struct migrant_lib::migration::EmbeddedMigration [−][src]
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
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]
fn clone(&self) -> EmbeddedMigration
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for EmbeddedMigration
[src]
impl Migratable for EmbeddedMigration
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,