Skip to main content

MigrationOperation

Enum MigrationOperation 

Source
pub enum MigrationOperation {
Show 26 variants CreateSchema { name: String, }, CreateTable { table: TableModel, }, RenameTable { schema: String, old_name: String, new_name: String, }, DropTable { schema: String, name: String, }, AddColumn { schema: String, table: String, column: ColumnModel, }, DropColumn { schema: String, table: String, name: String, }, RenameColumn { schema: String, table: String, old_name: String, new_name: String, }, AlterColumnType { schema: String, table: String, column: String, old_type: String, new_type: String, }, SetNotNull { schema: String, table: String, column: String, }, DropNotNull { schema: String, table: String, column: String, }, SetDefault { schema: String, table: String, column: String, default_sql: String, }, DropDefault { schema: String, table: String, column: String, }, AddPrimaryKey { schema: String, table: String, columns: Vec<String>, }, DropPrimaryKey { schema: String, table: String, name: String, }, AddUnique { schema: String, table: String, name: Option<String>, columns: Vec<String>, }, DropUnique { schema: String, table: String, name: Option<String>, }, AddForeignKey { schema: String, table: String, fk: ForeignKeyModel, }, DropForeignKey { schema: String, table: String, name: Option<String>, }, AddIndex { schema: String, table: String, index: IndexModel, }, DropIndex { schema: String, table: String, name: String, }, SetTableComment { schema: String, table: String, comment: Option<String>, }, SetColumnComment { schema: String, table: String, column: String, comment: Option<String>, }, CreateFunction { function: FunctionModel, }, ReplaceFunction { function: FunctionModel, }, DropFunction { function: FunctionModel, }, SetFunctionComment { schema: String, name: String, identity_arguments: String, comment: Option<String>, },
}
Expand description

单个迁移操作。

Variants§

§

CreateSchema

创建 schema

Fields

§name: String
§

CreateTable

创建表(含主键/唯一/外键,DDL 内联生成)

Fields

§

RenameTable

表重命名

Fields

§schema: String
§old_name: String
§new_name: String
§

DropTable

删除表(危险)

Fields

§schema: String
§name: String
§

AddColumn

新增字段

Fields

§schema: String
§table: String
§

DropColumn

删除字段(危险)

Fields

§schema: String
§table: String
§name: String
§

RenameColumn

字段重命名

Fields

§schema: String
§table: String
§old_name: String
§new_name: String
§

AlterColumnType

修改字段类型

Fields

§schema: String
§table: String
§column: String
§old_type: String
§new_type: String
§

SetNotNull

设置 NOT NULL(危险)

Fields

§schema: String
§table: String
§column: String
§

DropNotNull

取消 NOT NULL(安全)

Fields

§schema: String
§table: String
§column: String
§

SetDefault

设置默认值

Fields

§schema: String
§table: String
§column: String
§default_sql: String
§

DropDefault

删除默认值

Fields

§schema: String
§table: String
§column: String
§

AddPrimaryKey

添加主键(危险)

Fields

§schema: String
§table: String
§columns: Vec<String>
§

DropPrimaryKey

删除主键(危险)

Fields

§schema: String
§table: String
§name: String
§

AddUnique

添加唯一约束

Fields

§schema: String
§table: String
§columns: Vec<String>
§

DropUnique

删除唯一约束(危险)

Fields

§schema: String
§table: String
§

AddForeignKey

添加外键

Fields

§schema: String
§table: String
§

DropForeignKey

删除外键

Fields

§schema: String
§table: String
§

AddIndex

添加普通索引

Fields

§schema: String
§table: String
§

DropIndex

删除普通索引

Fields

§schema: String
§table: String
§name: String
§

SetTableComment

设置或删除表注释

Fields

§schema: String
§table: String
§comment: Option<String>
§

SetColumnComment

设置或删除字段注释

Fields

§schema: String
§table: String
§column: String
§comment: Option<String>
§

CreateFunction

创建数据库函数

Fields

§function: FunctionModel
§

ReplaceFunction

替换数据库函数定义

Fields

§function: FunctionModel
§

DropFunction

删除数据库函数

Fields

§function: FunctionModel
§

SetFunctionComment

设置或删除函数注释

Fields

§schema: String
§name: String
§identity_arguments: String
§comment: Option<String>

Implementations§

Source§

impl MigrationOperation

Source

pub fn danger(&self) -> DangerLevel

操作的危险等级。

Source

pub fn describe(&self) -> String

操作的人类可读描述(用于 plan 输出)。

Trait Implementations§

Source§

impl Clone for MigrationOperation

Source§

fn clone(&self) -> MigrationOperation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for MigrationOperation

Source§

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

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

impl<'de> Deserialize<'de> for MigrationOperation

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<MigrationOperation, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for MigrationOperation

Source§

impl PartialEq for MigrationOperation

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for MigrationOperation

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for MigrationOperation

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.