Skip to main content

Engine

Trait Engine 

Source
pub trait Engine: Send + Sync {
    // Required methods
    fn execute_with_writer<'life0, 'async_trait>(
        &'life0 self,
        write_fn: WriterFn,
        stdout_writer: StdoutWriter,
        merge_stderr: bool,
    ) -> Pin<Box<dyn Future<Output = Result<(), EngineError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn migration_apply<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        migration_name: &'life1 str,
        write_fn: WriterFn,
        pin_hash: Option<String>,
        namespace: &'life2 str,
        retry: bool,
    ) -> Pin<Box<dyn Future<Output = MigrationResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn migration_adopt<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        migration_name: &'life1 str,
        namespace: &'life2 str,
        description: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = MigrationResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn get_migrations_from_db<'life0, 'life1, 'async_trait>(
        &'life0 self,
        namespace: Option<&'life1 str>,
    ) -> Pin<Box<dyn Future<Output = MigrationResult<Vec<MigrationDbInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}

Required Methods§

Source

fn execute_with_writer<'life0, 'async_trait>( &'life0 self, write_fn: WriterFn, stdout_writer: StdoutWriter, merge_stderr: bool, ) -> Pin<Box<dyn Future<Output = Result<(), EngineError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Execute SQL by running the provided writer function.

  • write_fn: Closure that writes SQL to the provided Write handle
  • stdout_writer: Optional writer to capture stdout. If None, stdout is discarded.
  • merge_stderr: If true and stdout_writer is Some, stderr is merged into stdout at the OS level for true interleaving. Useful for tests. Note: when merged, stderr is not separately available in errors. Engine-specific setup (like psql flags) is handled internally. Returns stderr content on failure.
Source

fn migration_apply<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, migration_name: &'life1 str, write_fn: WriterFn, pin_hash: Option<String>, namespace: &'life2 str, retry: bool, ) -> Pin<Box<dyn Future<Output = MigrationResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn migration_adopt<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, migration_name: &'life1 str, namespace: &'life2 str, description: &'life3 str, ) -> Pin<Box<dyn Future<Output = MigrationResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Adopt a migration without applying it. Creates a dummy table entry marking the migration as having been applied manually. Sets checksum to empty and status to ‘SUCCESS’.

Source

fn get_migrations_from_db<'life0, 'life1, 'async_trait>( &'life0 self, namespace: Option<&'life1 str>, ) -> Pin<Box<dyn Future<Output = MigrationResult<Vec<MigrationDbInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get database information for all migrations in the given namespace. If namespace is None, returns migrations from all namespaces. Returns a list of migrations that exist in the database with their latest history entry.

Implementors§