| 1 | use crate::error::{BoxDynError, Error}; |
| 2 | |
| 3 | #[derive(Debug, thiserror::Error)] |
| 4 | #[non_exhaustive] |
| 5 | pub enum MigrateError { |
| 6 | #[error("while executing migrations: {0}")] |
| 7 | Execute(#[from] Error), |
| 8 | |
| 9 | #[error("while executing migration {1}: {0}")] |
| 10 | ExecuteMigration(#[source] Error, i64), |
| 11 | |
| 12 | #[error("while resolving migrations: {0}")] |
| 13 | Source(#[source] BoxDynError), |
| 14 | |
| 15 | #[error("migration {0} was previously applied but is missing in the resolved migrations")] |
| 16 | VersionMissing(i64), |
| 17 | |
| 18 | #[error("migration {0} was previously applied but has been modified")] |
| 19 | VersionMismatch(i64), |
| 20 | |
| 21 | #[error("migration {0} is not present in the migration source")] |
| 22 | VersionNotPresent(i64), |
| 23 | |
| 24 | #[error("migration {0} is older than the latest applied migration {1}")] |
| 25 | VersionTooOld(i64, i64), |
| 26 | |
| 27 | #[error("migration {0} is newer than the latest applied migration {1}")] |
| 28 | VersionTooNew(i64, i64), |
| 29 | |
| 30 | #[error("database driver does not support force-dropping a database (Only PostgreSQL)")] |
| 31 | ForceNotSupported, |
| 32 | |
| 33 | #[deprecated = "migration types are now inferred"] |
| 34 | #[error("cannot mix reversible migrations with simple migrations. All migrations should be reversible or simple migrations")] |
| 35 | InvalidMixReversibleAndSimple, |
| 36 | |
| 37 | // NOTE: this will only happen with a database that does not have transactional DDL (.e.g, MySQL or Oracle) |
| 38 | #[error( |
| 39 | "migration {0} is partially applied; fix and remove row from `_sqlx_migrations` table" |
| 40 | )] |
| 41 | Dirty(i64), |
| 42 | } |