Trait Operation

Source
pub trait Operation<DB>: Send + Sync
where DB: Database,
{ // Required method fn up<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 mut <DB as Database>::Connection, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn down<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 mut <DB as Database>::Connection, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn is_destructible(&self) -> bool { ... } }
Expand description

Trait for defining a database operation.

An Operation represents action that can be applied to or reverted from a database during a migration. Each operation can have an up method for applying the change and an optional down method for rolling it back.

Operations can also specify whether they are destructible meaning that they require user confirmation before being applied, due to potential data loss or irreversible changes

Required Methods§

Source

fn up<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 mut <DB as Database>::Connection, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The up method executes the operation when applying the migration.

This method is called when the migration is being applied to the database. Implement this method to define the changes you want to apply.

Provided Methods§

Source

fn down<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 mut <DB as Database>::Connection, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

The down method reverses the operation when rolling back the migration.

This method is called when the migration is being rolled back. Implement this method if you want to make the operation reversible. If not implemented, the operation is considered irreversible.

Source

fn is_destructible(&self) -> bool

Indicates whether the up operation is destructible.

If the operation is destructible, the user will be prompted for confirmation before running the migration via the CLI, due to the potential for data loss or irreversible changes. By default, up operations are considered non-destructible. Note that down operations are always considered destructible and cannot be changed.

Implementations on Foreign Types§

Source§

impl<DB, U, D> Operation<DB> for (U, D)
where DB: Database, U: AsRef<str> + Send + Sync, D: AsRef<str> + Send + Sync, for<'c> &'c mut <DB as Database>::Connection: Executor<'c, Database = DB>, for<'q> <DB as Database>::Arguments<'q>: IntoArguments<'q, DB>,

Source§

fn up<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 mut <DB as Database>::Connection, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn down<'life0, 'life1, 'async_trait>( &'life0 self, connection: &'life1 mut <DB as Database>::Connection, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§