Struct migrant_lib::migration::FnMigration [−][src]
Define a programmable migration
FnMigration
s are provided a ConnConfig
instance and given free rein to do as they please.
Database specific features (d-postgres
/d-sqlite
/d-mysql
) are required to use this functionality.
Note, both an up
and down
function must be provided. There is a noop function available
(migrant_lib::migration::noop
) for convenience.
Example
fn add_data(config: ConnConfig) -> Result<(), Box<dyn std::error::Error>> { // do stuff... Ok(()) } FnMigration::with_tag("add-user-data") .up(add_data) .down(migrant_lib::migration::noop);
Fields
tag: String
up: Option<T>
down: Option<U>
Implementations
impl<T, U> FnMigration<T, U> where
T: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
U: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
[src]
T: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
U: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
pub fn with_tag(_tag: &str) -> DatabaseFeatureRequired
[src]
Create a new FnMigration
with the given tag
pub fn up(&mut self, f_up: T) -> &mut Self
[src]
Function to use for up
migrations
Function must have the signature fn(ConnConfig) -> std::result::Result<(), Box<dyn std::error::Error>>
.
pub fn down(&mut self, f_down: U) -> &mut Self
[src]
Function to use for down
migrations
Function must have the signature fn(ConnConfig) -> std::result::Result<(), Box<dyn std::error::Error>>
.
pub fn boxed(&self) -> Box<dyn Migratable>
[src]
Box this migration up so it can be stored with other migrations
Trait Implementations
impl<T: Clone, U: Clone> Clone for FnMigration<T, U>
[src]
fn clone(&self) -> FnMigration<T, U>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug, U: Debug> Debug for FnMigration<T, U>
[src]
impl<T, U> Migratable for FnMigration<T, U> where
T: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
U: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
[src]
T: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
U: 'static + Clone + Fn(ConnConfig<'_>) -> Result<(), Box<dyn Error>>,
Auto Trait Implementations
impl<T, U> RefUnwindSafe for FnMigration<T, U> where
T: RefUnwindSafe,
U: RefUnwindSafe,
T: RefUnwindSafe,
U: RefUnwindSafe,
impl<T, U> Send for FnMigration<T, U> where
T: Send,
U: Send,
T: Send,
U: Send,
impl<T, U> Sync for FnMigration<T, U> where
T: Sync,
U: Sync,
T: Sync,
U: Sync,
impl<T, U> Unpin for FnMigration<T, U> where
T: Unpin,
U: Unpin,
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for FnMigration<T, U> where
T: UnwindSafe,
U: UnwindSafe,
T: UnwindSafe,
U: UnwindSafe,
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>,