use super::field;
use crate::database::migrations::CustomMigrationError;
use crate::database::versions::history::Entry;
use crate::database::DatabaseConnection;
pub async fn entry(
connection: &DatabaseConnection,
name: &str,
) -> Result<Option<Entry>, CustomMigrationError> {
let Some(done) = field::read(connection, name, "CAST(done AS TEXT)").await? else {
return Ok(None);
};
Ok(Some(Entry {
name: name.to_string(),
parent: super::parent_of(connection, name).await?,
done: is_true(&done),
migration_type: field::read(connection, name, "migration_type")
.await?
.unwrap_or_default(),
}))
}
fn is_true(value: &str) -> bool {
matches!(value, "true" | "t" | "1" | "TRUE")
}