pub trait MigrationPersistence: Send + Sync {
// Required methods
fn baseline_initialize(&mut self) -> BoxFuture<'_, ConnectorResult<()>>;
fn initialize(
&mut self,
namespaces: Option<Namespaces>
) -> BoxFuture<'_, ConnectorResult<()>>;
fn mark_migration_applied_impl<'a>(
&'a mut self,
migration_name: &'a str,
checksum: &'a str
) -> BoxFuture<'a, ConnectorResult<String>>;
fn mark_migration_rolled_back_by_id<'a>(
&'a mut self,
migration_id: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>;
fn record_migration_started_impl<'a>(
&'a mut self,
migration_name: &'a str,
checksum: &'a str
) -> BoxFuture<'a, ConnectorResult<String>>;
fn record_successful_step<'a>(
&'a mut self,
id: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>;
fn record_failed_step<'a>(
&'a mut self,
id: &'a str,
logs: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>;
fn record_migration_finished<'a>(
&'a mut self,
id: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>;
fn list_migrations(
&mut self
) -> BoxFuture<'_, ConnectorResult<Result<Vec<MigrationRecord>, PersistenceNotInitializedError>>>;
// Provided methods
fn mark_migration_applied<'a>(
&'a mut self,
migration_name: &'a str,
script: &'a str
) -> BoxFuture<'a, ConnectorResult<String>> { ... }
fn record_migration_started<'a>(
&'a mut self,
migration_name: &'a str,
script: &'a str
) -> BoxFuture<'a, ConnectorResult<String>> { ... }
}
Expand description
Management of imperative migrations state in the database.
Required Methods§
sourcefn baseline_initialize(&mut self) -> BoxFuture<'_, ConnectorResult<()>>
fn baseline_initialize(&mut self) -> BoxFuture<'_, ConnectorResult<()>>
Initialize the migration persistence without checking the database first.
sourcefn initialize(
&mut self,
namespaces: Option<Namespaces>
) -> BoxFuture<'_, ConnectorResult<()>>
fn initialize( &mut self, namespaces: Option<Namespaces> ) -> BoxFuture<'_, ConnectorResult<()>>
This method is responsible for checking whether the migrations persistence is initialized.
If the migration persistence is not present in the target database, check whether the database schema is empty. If it is, initialize the migration persistence. If not, return a DatabaseSchemaNotEmpty error.
sourcefn mark_migration_applied_impl<'a>(
&'a mut self,
migration_name: &'a str,
checksum: &'a str
) -> BoxFuture<'a, ConnectorResult<String>>
fn mark_migration_applied_impl<'a>( &'a mut self, migration_name: &'a str, checksum: &'a str ) -> BoxFuture<'a, ConnectorResult<String>>
Implementation in the connector for the core’s MarkMigrationApplied command. See the docs there. Note that the started_at and finished_at for the migration should be the same.
sourcefn mark_migration_rolled_back_by_id<'a>(
&'a mut self,
migration_id: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>
fn mark_migration_rolled_back_by_id<'a>( &'a mut self, migration_id: &'a str ) -> BoxFuture<'a, ConnectorResult<()>>
Mark the failed instances of the migration in the persistence as rolled back, so they will be ignored by the engine in the future.
sourcefn record_migration_started_impl<'a>(
&'a mut self,
migration_name: &'a str,
checksum: &'a str
) -> BoxFuture<'a, ConnectorResult<String>>
fn record_migration_started_impl<'a>( &'a mut self, migration_name: &'a str, checksum: &'a str ) -> BoxFuture<'a, ConnectorResult<String>>
Record that a migration is about to be applied. Returns the unique identifier for the migration.
This is an implementation detail, consumers should use
record_migration_started()
instead.
sourcefn record_successful_step<'a>(
&'a mut self,
id: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>
fn record_successful_step<'a>( &'a mut self, id: &'a str ) -> BoxFuture<'a, ConnectorResult<()>>
Increase the applied_steps_count counter.
sourcefn record_failed_step<'a>(
&'a mut self,
id: &'a str,
logs: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>
fn record_failed_step<'a>( &'a mut self, id: &'a str, logs: &'a str ) -> BoxFuture<'a, ConnectorResult<()>>
Report logs for a failed migration step. We assume the next steps in the migration will not be applied, and the error reported.
sourcefn record_migration_finished<'a>(
&'a mut self,
id: &'a str
) -> BoxFuture<'a, ConnectorResult<()>>
fn record_migration_finished<'a>( &'a mut self, id: &'a str ) -> BoxFuture<'a, ConnectorResult<()>>
Record that the migration completed successfully. This means
populating the finished_at
field in the migration record.
sourcefn list_migrations(
&mut self
) -> BoxFuture<'_, ConnectorResult<Result<Vec<MigrationRecord>, PersistenceNotInitializedError>>>
fn list_migrations( &mut self ) -> BoxFuture<'_, ConnectorResult<Result<Vec<MigrationRecord>, PersistenceNotInitializedError>>>
List all applied migrations, ordered by started_at
. This should fail
with a PersistenceNotInitializedError when the migration persistence is
not initialized.
Provided Methods§
sourcefn mark_migration_applied<'a>(
&'a mut self,
migration_name: &'a str,
script: &'a str
) -> BoxFuture<'a, ConnectorResult<String>>
fn mark_migration_applied<'a>( &'a mut self, migration_name: &'a str, script: &'a str ) -> BoxFuture<'a, ConnectorResult<String>>
Implementation in the connector for the core’s MarkMigrationApplied command. See the docs there. Note that the started_at and finished_at for the migration should be the same.
Connectors should implement mark_migration_applied_impl to avoid doing the checksuming themselves.
sourcefn record_migration_started<'a>(
&'a mut self,
migration_name: &'a str,
script: &'a str
) -> BoxFuture<'a, ConnectorResult<String>>
fn record_migration_started<'a>( &'a mut self, migration_name: &'a str, script: &'a str ) -> BoxFuture<'a, ConnectorResult<String>>
Record that a migration is about to be applied. Returns the unique identifier for the migration.
This is a default method that computes the checksum. Implementors should implement record_migration_started_impl.