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
impl Operation
Sourcepub fn drop_table(name: impl Into<String>) -> Self
pub fn drop_table(name: impl Into<String>) -> Self
Creates a drop table operation.
Sourcepub fn drop_table_if_exists(name: impl Into<String>) -> Self
pub fn drop_table_if_exists(name: impl Into<String>) -> Self
Creates a drop table if exists operation.
Sourcepub fn rename_table(
old_name: impl Into<String>,
new_name: impl Into<String>,
) -> Self
pub fn rename_table( old_name: impl Into<String>, new_name: impl Into<String>, ) -> Self
Creates a rename table operation.
Sourcepub fn add_column(table: impl Into<String>, column: ColumnDefinition) -> Self
pub fn add_column(table: impl Into<String>, column: ColumnDefinition) -> Self
Creates an add column operation.
Sourcepub fn drop_column(table: impl Into<String>, column: impl Into<String>) -> Self
pub fn drop_column(table: impl Into<String>, column: impl Into<String>) -> Self
Creates a drop column operation.
Sourcepub fn rename_column(
table: impl Into<String>,
old_name: impl Into<String>,
new_name: impl Into<String>,
) -> Self
pub fn rename_column( table: impl Into<String>, old_name: impl Into<String>, new_name: impl Into<String>, ) -> Self
Creates a rename column operation.
Sourcepub fn run_sql_reversible(
up_sql: impl Into<String>,
down_sql: impl Into<String>,
) -> Self
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.
Sourcepub fn reverse(&self) -> Option<Self>
pub fn reverse(&self) -> Option<Self>
Attempts to generate the reverse operation.
Returns None if the operation is not reversible.
Sourcepub fn is_reversible(&self) -> bool
pub fn is_reversible(&self) -> bool
Returns whether this operation is reversible.
Trait Implementations§
Source§impl From<AddColumnOp> for Operation
impl From<AddColumnOp> for Operation
Source§fn from(op: AddColumnOp) -> Self
fn from(op: AddColumnOp) -> Self
Converts to this type from the input type.
Source§impl From<AddForeignKeyOp> for Operation
impl From<AddForeignKeyOp> for Operation
Source§fn from(op: AddForeignKeyOp) -> Self
fn from(op: AddForeignKeyOp) -> Self
Converts to this type from the input type.
Source§impl From<AlterColumnOp> for Operation
impl From<AlterColumnOp> for Operation
Source§fn from(op: AlterColumnOp) -> Self
fn from(op: AlterColumnOp) -> Self
Converts to this type from the input type.
Source§impl From<CreateIndexOp> for Operation
impl From<CreateIndexOp> for Operation
Source§fn from(op: CreateIndexOp) -> Self
fn from(op: CreateIndexOp) -> Self
Converts to this type from the input type.
Source§impl From<CreateTableOp> for Operation
impl From<CreateTableOp> for Operation
Source§fn from(op: CreateTableOp) -> Self
fn from(op: CreateTableOp) -> Self
Converts to this type from the input type.
Source§impl From<DropColumnOp> for Operation
impl From<DropColumnOp> for Operation
Source§fn from(op: DropColumnOp) -> Self
fn from(op: DropColumnOp) -> Self
Converts to this type from the input type.
Source§impl From<DropForeignKeyOp> for Operation
impl From<DropForeignKeyOp> for Operation
Source§fn from(op: DropForeignKeyOp) -> Self
fn from(op: DropForeignKeyOp) -> Self
Converts to this type from the input type.
Source§impl From<DropIndexOp> for Operation
impl From<DropIndexOp> for Operation
Source§fn from(op: DropIndexOp) -> Self
fn from(op: DropIndexOp) -> Self
Converts to this type from the input type.
Source§impl From<DropTableOp> for Operation
impl From<DropTableOp> for Operation
Source§fn from(op: DropTableOp) -> Self
fn from(op: DropTableOp) -> Self
Converts to this type from the input type.
Source§impl From<RenameColumnOp> for Operation
impl From<RenameColumnOp> for Operation
Source§fn from(op: RenameColumnOp) -> Self
fn from(op: RenameColumnOp) -> Self
Converts to this type from the input type.
Source§impl From<RenameTableOp> for Operation
impl From<RenameTableOp> for Operation
Source§fn from(op: RenameTableOp) -> Self
fn from(op: RenameTableOp) -> Self
Converts to this type from the input type.
impl StructuralPartialEq for Operation
Auto Trait Implementations§
impl Freeze for Operation
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnwindSafe for Operation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more