Skip to main content

DatabaseSeeder

Trait DatabaseSeeder 

Source
pub trait DatabaseSeeder: Send + Sync {
    // Required methods
    fn seed<'life0, 'async_trait>(
        &'life0 self,
        txn: Arc<DatabaseTransaction>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        txn: Arc<DatabaseTransaction>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn name(&self) -> &str { ... }
    fn order(&self) -> i32 { ... }
}
Expand description

Trait for database seeders.

Implementations receive an Arc<DatabaseTransaction> so all work runs inside the runner’s single transaction while the handle stays freely shareable (e.g., for nested repository calls via RepositoryOptions). Do not retain clones beyond the call: committing requires sole ownership.

Required Methods§

Source

fn seed<'life0, 'async_trait>( &'life0 self, txn: Arc<DatabaseTransaction>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Inserts seeded data inside the given transaction.

Source

fn delete<'life0, 'async_trait>( &'life0 self, txn: Arc<DatabaseTransaction>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes seeded data inside the given transaction.

Provided Methods§

Source

fn name(&self) -> &str

Returns the unique tracking name; defaults to the type name.

Source

fn order(&self) -> i32

Returns the execution order (lower runs first, default 0).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§