Skip to main content

a3s_orm/migration/
backend.rs

1use async_trait::async_trait;
2
3use super::{AppliedMigration, MigrationReport, PreparedMigration};
4
5/// Reads the migration ledger without creating or changing database objects.
6///
7/// Serving processes use this boundary to prove that their required schema is
8/// already present while retaining a database role that has no DDL authority.
9#[async_trait]
10pub trait MigrationLedger: Send + Sync {
11    type Error: std::error::Error + Send + Sync + 'static;
12
13    async fn applied_migrations(&self) -> Result<Vec<AppliedMigration>, Self::Error>;
14}
15
16/// Applies an already validated migration set.
17///
18/// Implementations must serialize concurrent migrators, verify previously
19/// applied checksums, and atomically record every migration they apply.
20#[async_trait]
21pub trait MigrationBackend: Send + Sync {
22    type Error: std::error::Error + Send + Sync + 'static;
23
24    async fn apply(&self, migrations: &[PreparedMigration])
25        -> Result<MigrationReport, Self::Error>;
26}