Operation

Enum Operation 

Source
pub enum Operation {
    CreateTable(CreateTableOp),
    DropTable(DropTableOp),
    RenameTable(RenameTableOp),
    AddColumn(AddColumnOp),
    DropColumn(DropColumnOp),
    AlterColumn(AlterColumnOp),
    RenameColumn(RenameColumnOp),
    CreateIndex(CreateIndexOp),
    DropIndex(DropIndexOp),
    AddForeignKey(AddForeignKeyOp),
    DropForeignKey(DropForeignKeyOp),
    RunSql(RawSqlOp),
}
Expand description

All possible migration operations.

Variants§

§

CreateTable(CreateTableOp)

Create a new table.

§

DropTable(DropTableOp)

Drop an existing table.

§

RenameTable(RenameTableOp)

Rename a table.

§

AddColumn(AddColumnOp)

Add a column to an existing table.

§

DropColumn(DropColumnOp)

Drop a column from a table.

§

AlterColumn(AlterColumnOp)

Alter a column definition.

§

RenameColumn(RenameColumnOp)

Rename a column.

§

CreateIndex(CreateIndexOp)

Create an index.

§

DropIndex(DropIndexOp)

Drop an index.

§

AddForeignKey(AddForeignKeyOp)

Add a foreign key constraint.

§

DropForeignKey(DropForeignKeyOp)

Drop a foreign key constraint.

§

RunSql(RawSqlOp)

Run raw SQL.

Implementations§

Source§

impl Operation

Source

pub fn drop_table(name: impl Into<String>) -> Self

Creates a drop table operation.

Source

pub fn drop_table_if_exists(name: impl Into<String>) -> Self

Creates a drop table if exists operation.

Source

pub fn rename_table( old_name: impl Into<String>, new_name: impl Into<String>, ) -> Self

Creates a rename table operation.

Source

pub fn add_column(table: impl Into<String>, column: ColumnDefinition) -> Self

Creates an add column operation.

Source

pub fn drop_column(table: impl Into<String>, column: impl Into<String>) -> Self

Creates a drop column operation.

Source

pub fn rename_column( table: impl Into<String>, old_name: impl Into<String>, new_name: impl Into<String>, ) -> Self

Creates a rename column operation.

Source

pub fn run_sql(sql: impl Into<String>) -> Self

Creates a raw SQL operation.

Source

pub fn run_sql_reversible( up_sql: impl Into<String>, down_sql: impl Into<String>, ) -> Self

Creates a raw SQL operation with both up and down SQL.

Source

pub fn reverse(&self) -> Option<Self>

Attempts to generate the reverse operation.

Returns None if the operation is not reversible.

Source

pub fn is_reversible(&self) -> bool

Returns whether this operation is reversible.

Trait Implementations§

Source§

impl Clone for Operation

Source§

fn clone(&self) -> Operation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Operation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<AddColumnOp> for Operation

Source§

fn from(op: AddColumnOp) -> Self

Converts to this type from the input type.
Source§

impl From<AddForeignKeyOp> for Operation

Source§

fn from(op: AddForeignKeyOp) -> Self

Converts to this type from the input type.
Source§

impl From<AlterColumnOp> for Operation

Source§

fn from(op: AlterColumnOp) -> Self

Converts to this type from the input type.
Source§

impl From<CreateIndexOp> for Operation

Source§

fn from(op: CreateIndexOp) -> Self

Converts to this type from the input type.
Source§

impl From<CreateTableOp> for Operation

Source§

fn from(op: CreateTableOp) -> Self

Converts to this type from the input type.
Source§

impl From<DropColumnOp> for Operation

Source§

fn from(op: DropColumnOp) -> Self

Converts to this type from the input type.
Source§

impl From<DropForeignKeyOp> for Operation

Source§

fn from(op: DropForeignKeyOp) -> Self

Converts to this type from the input type.
Source§

impl From<DropIndexOp> for Operation

Source§

fn from(op: DropIndexOp) -> Self

Converts to this type from the input type.
Source§

impl From<DropTableOp> for Operation

Source§

fn from(op: DropTableOp) -> Self

Converts to this type from the input type.
Source§

impl From<RawSqlOp> for Operation

Source§

fn from(op: RawSqlOp) -> Self

Converts to this type from the input type.
Source§

impl From<RenameColumnOp> for Operation

Source§

fn from(op: RenameColumnOp) -> Self

Converts to this type from the input type.
Source§

impl From<RenameTableOp> for Operation

Source§

fn from(op: RenameTableOp) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Operation

Source§

fn eq(&self, other: &Operation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Operation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.