[][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 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]

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 !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]

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

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

impl<T> From<T> for T[src]

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

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.