Skip to main content

SchemaMutations

Struct SchemaMutations 

Source
pub struct SchemaMutations {
    pub alter_column_type: bool,
    pub alter_column_properties_atomic: bool,
}
Expand description

The database’s capabilities to mutate the schema (tables, columns, indices).

Used by the migration generator to decide how to express each column change. alter_column_type gates whether an in-place ALTER COLUMN is possible at all — SQLite has it set to false, and a type change there triggers a full table rebuild (create new table, copy rows, drop old). alter_column_properties_atomic decides whether several column-property changes (rename, retype, NOT NULL, default) collapse into one statement or emit one per property. MySQL sets both to true; PostgreSQL alters in place but requires one statement per property.

Pre-built configurations: SQLITE, POSTGRESQL, MYSQL, DYNAMODB.

§Examples

Access through Capability::schema_mutations:

use toasty_core::driver::Capability;

let cap = &Capability::POSTGRESQL;
assert!(cap.schema_mutations.alter_column_type);
assert!(!cap.schema_mutations.alter_column_properties_atomic);

Fields§

§alter_column_type: bool

Whether the database can change the type of an existing column.

§alter_column_properties_atomic: bool

Whether the database can change name, type and constraints of a column all withing a single statement.

Implementations§

Source§

impl SchemaMutations

Source

pub const SQLITE: Self

SQLite schema mutation capabilities. SQLite cannot alter column types.

Source

pub const POSTGRESQL: Self

PostgreSQL schema mutation capabilities. Supports altering column types but not atomically changing multiple column properties.

Source

pub const MYSQL: Self

MySQL schema mutation capabilities. Supports altering column types and atomically changing multiple column properties in a single statement.

Source

pub const DYNAMODB: Self

DynamoDB schema mutation capabilities. Migrations are not currently supported.

Trait Implementations§

Source§

impl Debug for SchemaMutations

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.