mod schema;
use super::exec;
use crate::database::migrations::CustomMigrationError;
use crate::database::DatabaseConnection;
pub use schema::{HISTORY_TABLE, TYPE_BASELINE, TYPE_MIGRATION};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Entry {
pub name: String,
pub parent: Option<String>,
pub done: bool,
pub migration_type: String,
}
impl Entry {
pub fn is_baseline(&self) -> bool {
self.migration_type == TYPE_BASELINE
}
}
pub async fn ensure_table(connection: &DatabaseConnection) -> Result<(), CustomMigrationError> {
exec::run(connection, &schema::create_table(), &[]).await?;
for statement in schema::create_indexes() {
let _ = exec::run(connection, &statement, &[]).await;
}
Ok(())
}