[−][src]Struct migrant_lib::migration::FnMigration
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<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>
Methods
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]
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>>,
pub fn with_tag(_tag: &str) -> DatabaseFeatureRequired
[src]
pub fn with_tag(_tag: &str) -> DatabaseFeatureRequired
Create a new FnMigration
with the given tag
pub fn up(&mut self, f_up: T) -> &mut Self
[src]
pub fn up(&mut self, f_up: T) -> &mut Self
Function to use for up
migrations
Function must have the signature fn(ConnConfig) -> std::result::Result<(), Box<std::error::Error>>
.
pub fn down(&mut self, f_down: U) -> &mut Self
[src]
pub fn down(&mut self, f_down: U) -> &mut Self
Function to use for down
migrations
Function must have the signature fn(ConnConfig) -> std::result::Result<(), Box<std::error::Error>>
.
pub fn boxed(&self) -> Box<dyn Migratable>
[src]
pub fn boxed(&self) -> Box<dyn Migratable>
Box this migration up so it can be stored with other migrations
Trait Implementations
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]
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>>,
fn apply_up(&self, _: DbKind, config: &Config) -> Result<(), Box<dyn Error>>
[src]
fn apply_up(&self, _: DbKind, config: &Config) -> Result<(), Box<dyn Error>>
fn apply_down(&self, _: DbKind, config: &Config) -> Result<(), Box<dyn Error>>
[src]
fn apply_down(&self, _: DbKind, config: &Config) -> Result<(), Box<dyn Error>>
fn tag(&self) -> String
[src]
fn tag(&self) -> String
fn description(&self, _: &Direction) -> String
[src]
fn description(&self, _: &Direction) -> String
impl<T: Clone, U: Clone> Clone for FnMigration<T, U>
[src]
impl<T: Clone, U: Clone> Clone for FnMigration<T, U>
fn clone(&self) -> FnMigration<T, U>
[src]
fn clone(&self) -> FnMigration<T, U>
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<T: Debug, U: Debug> Debug for FnMigration<T, U>
[src]
impl<T: Debug, U: Debug> Debug for FnMigration<T, U>
Auto Trait Implementations
impl<T, U> Send for FnMigration<T, U> where
T: Send,
U: Send,
impl<T, U> Send for FnMigration<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for FnMigration<T, U> where
T: Sync,
U: Sync,
impl<T, U> Sync for FnMigration<T, U> where
T: Sync,
U: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId