pub enum SchemaOperation {
Show 17 variants
CreateTable(TableInfo),
DropTable(String),
RenameTable {
from: String,
to: String,
},
AddColumn {
table: String,
column: ColumnInfo,
},
DropColumn {
table: String,
column: String,
table_info: Option<TableInfo>,
},
AlterColumnType {
table: String,
column: String,
from_type: String,
to_type: String,
table_info: Option<TableInfo>,
},
AlterColumnNullable {
table: String,
column: ColumnInfo,
from_nullable: bool,
to_nullable: bool,
table_info: Option<TableInfo>,
},
AlterColumnDefault {
table: String,
column: String,
from_default: Option<String>,
to_default: Option<String>,
table_info: Option<TableInfo>,
},
RenameColumn {
table: String,
from: String,
to: String,
},
AddPrimaryKey {
table: String,
columns: Vec<String>,
table_info: Option<TableInfo>,
},
DropPrimaryKey {
table: String,
table_info: Option<TableInfo>,
},
AddForeignKey {
table: String,
fk: ForeignKeyInfo,
table_info: Option<TableInfo>,
},
DropForeignKey {
table: String,
name: String,
table_info: Option<TableInfo>,
},
AddUnique {
table: String,
constraint: UniqueConstraintInfo,
table_info: Option<TableInfo>,
},
DropUnique {
table: String,
name: String,
table_info: Option<TableInfo>,
},
CreateIndex {
table: String,
index: IndexInfo,
},
DropIndex {
table: String,
name: String,
},
}Expand description
A single schema modification operation.
Variants§
CreateTable(TableInfo)
Create a new table.
DropTable(String)
Drop an existing table.
RenameTable
Rename a table.
AddColumn
Add a column to a table.
DropColumn
Drop a column from a table.
For SQLite, safely dropping a column on versions < 3.35 requires table
recreation. When table_info is present, the SQLite DDL generator can
emit a correct recreate-copy-drop sequence (preserving indexes we track).
AlterColumnType
Change a column’s type.
AlterColumnNullable
Change a column’s nullability.
Fields
§
column: ColumnInfoAlterColumnDefault
Change a column’s default value.
Fields
RenameColumn
Rename a column.
AddPrimaryKey
Add a primary key constraint.
DropPrimaryKey
Drop a primary key constraint.
AddForeignKey
Add a foreign key constraint.
DropForeignKey
Drop a foreign key constraint.
AddUnique
Add a unique constraint.
DropUnique
Drop a unique constraint.
CreateIndex
Create an index.
DropIndex
Drop an index.
Implementations§
Source§impl SchemaOperation
impl SchemaOperation
Sourcepub fn is_destructive(&self) -> bool
pub fn is_destructive(&self) -> bool
Check if this operation potentially loses data.
Trait Implementations§
Source§impl Clone for SchemaOperation
impl Clone for SchemaOperation
Source§fn clone(&self) -> SchemaOperation
fn clone(&self) -> SchemaOperation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SchemaOperation
impl RefUnwindSafe for SchemaOperation
impl Send for SchemaOperation
impl Sync for SchemaOperation
impl Unpin for SchemaOperation
impl UnsafeUnpin for SchemaOperation
impl UnwindSafe for SchemaOperation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).