pub struct Migration {
pub name: String,
pub up: String,
pub down: String,
/* private fields */
}Expand description
One migration: its name, and what applies it (up) and reverts it (down). Either fixed SQL
(Migration::new, files) or schema statements (Migration::schema).
Fields§
§name: StringThe folder name, such as 20261108000000_create_users.
up: StringThe contents of up.sql. Empty for a schema migration, which carries
statements instead.
down: StringThe contents of down.sql. Empty for a schema migration.
Implementations§
Source§impl Migration
impl Migration
Sourcepub fn new(
name: impl Into<String>,
up: impl Into<String>,
down: impl Into<String>,
) -> Self
pub fn new( name: impl Into<String>, up: impl Into<String>, down: impl Into<String>, ) -> Self
A migration from its name and SQL, for code that builds migrations itself.
Sourcepub fn schema(
name: impl Into<String>,
up: Vec<Statement>,
down: Vec<Statement>,
) -> Self
pub fn schema( name: impl Into<String>, up: Vec<Statement>, down: Vec<Statement>, ) -> Self
A migration written with the schema builder. The statements are rendered for the connected database when the migrator runs or rolls it back, so one migration serves every database. A statement that cannot be rendered fails the migration with that error, before any of its SQL runs. The migration keeps the same transaction and batch behaviour as an SQL one.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Migration
impl Freeze for Migration
impl Move for Migration
impl RefUnwindSafe for Migration
impl Send for Migration
impl Sync for Migration
impl Unpin for Migration
impl UnsafeUnpin for Migration
impl UnwindSafe for Migration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more