pub struct RustMigration<Conn> { /* private fields */ }Expand description
A rust side migration
This type represents a simple rust side migration builder that allows you to register a rust callback as up and down migration and that also allows you to customize the migration settings
Constructing a RustMigration requires to specify an up migration that
describes how to migrate your database schema from an old to an new version.
Down migrations, that describe how to revert the changes done by the up migrations, are optional. If you don’t plan to revert migrations you don’t need to provide them.
Implementations§
Source§impl<Conn> RustMigration<Conn>
impl<Conn> RustMigration<Conn>
Sourcepub fn new(up: impl Fn(&mut Conn) -> QueryResult<()> + 'static) -> Self
pub fn new(up: impl Fn(&mut Conn) -> QueryResult<()> + 'static) -> Self
Construct a new instance of this type with a given up migration function.
This function needs to perform any action to migrate your database from an old version to the expected new version
Sourcepub fn with_down(
self,
down: impl Fn(&mut Conn) -> QueryResult<()> + 'static,
) -> Self
pub fn with_down( self, down: impl Fn(&mut Conn) -> QueryResult<()> + 'static, ) -> Self
Register a down migration
This function allows you to register a down migration to revert any changes done by the up migration. It is used to restore the database schema used before this migration was applied in the case of an revert. If you don’t plan to revert migrations you don’t need to provide a down migration.
Sourcepub fn without_transaction(self) -> Self
pub fn without_transaction(self) -> Self
Customizes the migration settings to not run this migration in a transaction
By default diesel will execute migrations inside of a transaction on all database systems supporting this to ensure that migrations are either fully executed or not.
Some database operations require to be run outside transactions. If you use such an operation in either your up or down migration you need to use this function to disable the default transaction behaviour.
Trait Implementations§
Source§impl<Conn> TypedMigration<Conn> for RustMigration<Conn>
impl<Conn> TypedMigration<Conn> for RustMigration<Conn>
Source§fn up(&self, conn: &mut Conn) -> QueryResult<()>
fn up(&self, conn: &mut Conn) -> QueryResult<()>
Source§fn down(&self, conn: &mut Conn) -> QueryResult<()>
fn down(&self, conn: &mut Conn) -> QueryResult<()>
Source§fn run_in_transaction(&self) -> bool
fn run_in_transaction(&self) -> bool
Auto Trait Implementations§
impl<Conn> !RefUnwindSafe for RustMigration<Conn>
impl<Conn> !Send for RustMigration<Conn>
impl<Conn> !Sync for RustMigration<Conn>
impl<Conn> !UnwindSafe for RustMigration<Conn>
impl<Conn> Freeze for RustMigration<Conn>
impl<Conn> Unpin for RustMigration<Conn>
impl<Conn> UnsafeUnpin for RustMigration<Conn>
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more