[][src]Struct barrel::migration::Migration

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]

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]

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]

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 !Send for Migration

impl !Sync for Migration

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> IntoSql for T[src]

fn into_sql<T>(self) -> Self::Expression where
    Self: AsExpression<T>, 
[src]

Convert self to an expression for Diesel's query builder. Read more

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression where
    &'a Self: AsExpression<T>, 
[src]

Convert &self to an expression for Diesel's query builder. Read more