[−][src]Struct barrel::migration::Migration
Represents a schema migration on a database
Methods
impl Migration
[src]
pub fn new() -> Migration
[src]
pub fn schema<S: Into<String>>(self, schema: S) -> Migration
[src]
Specify a database schema name for this migration
pub fn make<T: SqlGenerator>(&self) -> String
[src]
Creates the SQL for this migration for a specific backend
This function copies state and does not touch the original
migration layout. This allows you to call revert
later on
in the process to auto-infer the down-behaviour
pub fn make_from(&self, variant: SqlVariant) -> String
[src]
The same as make
but making a run-time check for sql variant
The SqlVariant
type is populated based on the backends
that are being selected at compile-time.
This function panics if the provided variant is empty!
pub fn revert<T: SqlGenerator>(&self) -> String
[src]
Automatically infer the down
step of this migration
Will thrown an error if behaviour is ambiguous or not
possible to infer (e.g. revert a drop_table
)
pub fn execute<S: SqlGenerator, T: SqlRunner>(&self, runner: &mut T)
[src]
Pass a reference to a migration toolkit runner which will automatically generate and execute
pub fn create_table<S: Into<String>, F: 'static>(
&mut self,
name: S,
cb: F
) -> &mut TableMeta where
F: Fn(&mut Table),
[src]
&mut self,
name: S,
cb: F
) -> &mut TableMeta where
F: Fn(&mut Table),
Create a new table with a specific name
pub fn create_table_if_not_exists<S: Into<String>, F: 'static>(
&mut self,
name: S,
cb: F
) -> &mut TableMeta where
F: Fn(&mut Table),
[src]
&mut self,
name: S,
cb: F
) -> &mut TableMeta where
F: Fn(&mut Table),
Create a new table only if it doesn't exist yet
pub fn change_table<S: Into<String>, F: 'static>(&mut self, name: S, cb: F) where
F: Fn(&mut Table),
[src]
F: Fn(&mut Table),
Change fields on an existing table
pub fn rename_table<S: Into<String>>(&mut self, old: S, new: S)
[src]
Rename a table
pub fn drop_table<S: Into<String>>(&mut self, name: S)
[src]
Drop an existing table
pub fn drop_table_if_exists<S: Into<String>>(&mut self, name: S)
[src]
Only drop a table if it exists
Auto Trait Implementations
impl !RefUnwindSafe for Migration
impl !Send for Migration
impl !Sync for Migration
impl Unpin for Migration
impl !UnwindSafe for Migration
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,
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, 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.
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>,