Struct barrel::migration::Migration
[−]
[src]
pub struct Migration { /* fields omitted */ }
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 revert<T: SqlGenerator>(&self) -> String
[src]
Automatically infer the down
step of this migration
Will thrown an error if behaviour is ambigous or not
possible to infer (e.g. revert a drop_table
)
pub fn execute<T: DatabaseExecutor, S: SqlGenerator>(&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