use crate::sql::sqlx;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum MigrateError {
#[error(transparent)]
Driver(#[from] sqlx::Error),
#[error("migration file I/O: {0}")]
Io(#[from] std::io::Error),
#[error("migration file JSON: {0}")]
Json(#[from] serde_json::Error),
#[error("invalid migration: {0}")]
Validation(String),
#[error(transparent)]
Exec(#[from] crate::sql::ExecError),
#[error(
"migration `{migration}` failed after completing {applied} of {total} operations, \
having already committed {ddl_applied} DDL statement(s).\n\
MySQL commits DDL immediately, so those {ddl_applied} are still applied and the \
transaction could not undo them. The ledger row was not written, so re-running \
replays from the top and will fail differently.\n\
Recovery: inspect the schema against this migration, then \
`manage migrate --fake {migration}` once it matches (add `--all-tenants` under \
tenancy).\n\
Cause: {source}"
)]
PartiallyApplied {
migration: String,
applied: usize,
total: usize,
ddl_applied: usize,
source: Box<sqlx::Error>,
},
}