use async_trait::async_trait;
use crate::error::Result;
use crate::migration::Migration;
#[derive(Debug)]
pub struct AppliedMigration {
pub version: u32,
pub file: String,
pub name: String,
pub checksum: String,
pub description: Option<String>,
pub batch: i32,
pub applied_at: sqlx::types::chrono::DateTime<sqlx::types::chrono::Utc>,
pub applied_by: String,
pub execution_ms: Option<i32>,
}
pub trait LockGuard: Send + Sync {}
#[async_trait]
pub trait MigrationDriver: Send + Sync {
async fn acquire_lock(&self) -> Result<Box<dyn LockGuard>>;
async fn run_setup_sql(&self, name: &str, sql: &str) -> Result<()>;
async fn ensure_tracking_table(&self) -> Result<()>;
async fn applied(&self) -> Result<Vec<AppliedMigration>>;
async fn apply(&self, migration: &Migration, up_sql: &str, batch: i32) -> Result<()>;
async fn revert(&self, applied: &AppliedMigration, down_sql: &str) -> Result<()>;
}