Skip to main content

MigrationOp

Enum MigrationOp 

Source
pub enum MigrationOp {
    CreateTable {
        name: String,
        schema: TableSchemaSnapshot,
    },
    DropTable {
        name: String,
    },
    AddColumn {
        table: String,
        column: ColumnSnapshot,
    },
    DropColumn {
        table: String,
        column: String,
    },
    RenameColumn {
        table: String,
        old: String,
        new: String,
    },
    AlterColumn {
        table: String,
        column: String,
        changes: ColumnChanges,
    },
    WidenColumn {
        table: String,
        column: String,
        old_type: DataTypeSnapshot,
        new_type: DataTypeSnapshot,
    },
    TransformColumn {
        column: String,
        table: String,
        old_type: DataTypeSnapshot,
        new_type: DataTypeSnapshot,
    },
    AddIndex {
        table: String,
        index: IndexSnapshot,
    },
    DropIndex {
        table: String,
        index: IndexSnapshot,
    },
}
Expand description

Single atomic step produced by the migration planner.

Ops are sorted into a deterministic apply order (creates → drops → renames → relaxations → widening/transforms → adds → tightenings → indexes → table drops) and then executed inside a single journaled session.

Variants§

§

CreateTable

Create a new table with the given snapshot.

Fields

§name: String

Name of the new table.

§schema: TableSchemaSnapshot

Snapshot of the compiled schema for the new table.

§

DropTable

Drop a table and all of its data. Destructive.

Fields

§name: String

Name of the table to drop.

§

AddColumn

Append a new column to an existing table.

If the column is non-nullable, the planner must have resolved a default value (#[default] or Migrate::default_value) before emitting this op.

Fields

§table: String

Table the column belongs to.

§column: ColumnSnapshot

Snapshot of the new column.

§

DropColumn

Drop a column and discard its data. Destructive.

Fields

§table: String

Table the column belongs to.

§column: String

Name of the column to drop.

§

RenameColumn

Rename a column, preserving its data and constraints.

Fields

§table: String

Table the column belongs to.

§old: String

Previous column name as it appears in the stored snapshot.

§new: String

New column name as it appears in the compiled snapshot.

§

AlterColumn

Change one or more constraint flags on an existing column.

Fields

§table: String

Table the column belongs to.

§column: String

Name of the column to alter.

§changes: ColumnChanges

Flag deltas to apply.

§

WidenColumn

Widen a column to a larger compatible type (sign-extend, zero-extend, Float32Float64).

Fields

§table: String

Table the column belongs to.

§column: String

Name of the column being widened.

§old_type: DataTypeSnapshot

Stored data type before widening.

§new_type: DataTypeSnapshot

Compiled data type after widening.

§

TransformColumn

Convert a column to an incompatible type using Migrate::transform_column.

Fields

§column: String

Table the column belongs to.

§table: String

Name of the column being transformed.

§old_type: DataTypeSnapshot

Stored data type before the transform.

§new_type: DataTypeSnapshot

Compiled data type after the transform.

§

AddIndex

Build a new secondary index.

Fields

§table: String

Table the index belongs to.

§index: IndexSnapshot

Snapshot of the new index.

§

DropIndex

Drop an existing secondary index.

Fields

§table: String

Table the index belongs to.

§index: IndexSnapshot

Snapshot of the index to drop.

Trait Implementations§

Source§

impl CandidType for MigrationOp

Source§

fn _ty() -> Type

Source§

fn _ty_doc() -> TypeDoc

Source§

fn id() -> TypeId

Source§

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

Source§

fn ty() -> Type

Source§

impl Clone for MigrationOp

Source§

fn clone(&self) -> MigrationOp

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 MigrationOp

Source§

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

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

impl<'de> Deserialize<'de> for MigrationOp

Source§

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

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

impl PartialEq for MigrationOp

Source§

fn eq(&self, other: &MigrationOp) -> 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 Serialize for MigrationOp

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 Eq for MigrationOp

Source§

impl StructuralPartialEq for MigrationOp

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> 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 = 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,