tern_derive

Derive Macro MigrationContext

Source
#[derive(MigrationContext)]
{
    // Attributes available to this derive:
    #[tern]
}
Expand description

MigrationContext implements the trait MigrationContext, which is required of a type to be suitable for use in a migration Runner. A bound of MigrationSource exists, which can be satisfied by hand or by using the derive macro provided here, MigrationSource. Custom, dynamic behavior for a migration can be defined for the context, which is available to QueryBuilder.

The macro exposes one one optional field attribute:

  • executor_via decorates the field of holding an Executor, which is required of the type to be a context. If not specified then it is expected that the type itself implements Executor.

ยงUsage

use tern::{SqlxPgExecutor, MigrationContext};

#[derive(MigrationContext)]
pub struct MyContext {
    #[tern(executor_via)]
    executor: SqlxPgExecutor,
}