Skip to main content

a3s_orm/migration/
error.rs

1#[derive(Debug, thiserror::Error, PartialEq, Eq)]
2pub enum MigrationError {
3    #[error("migration version cannot be empty")]
4    EmptyVersion,
5    #[error("migration {version:?} has an empty name")]
6    EmptyName { version: String },
7    #[error("migration {version:?} has empty SQL")]
8    EmptySql { version: String },
9    #[error("migration version contains unsupported characters: {0:?}")]
10    InvalidVersion(String),
11    #[error("duplicate migration version: {0:?}")]
12    DuplicateVersion(String),
13    #[error(
14        "migration {version:?} changed after it was applied (database {applied_checksum}, source {source_checksum})"
15    )]
16    ChecksumMismatch {
17        version: String,
18        applied_checksum: String,
19        source_checksum: String,
20    },
21    #[error("database contains migration {0:?} that is absent from the source")]
22    MissingSourceMigration(String),
23}
24
25#[derive(Debug, thiserror::Error)]
26pub enum MigrationRunError<E>
27where
28    E: std::error::Error + Send + Sync + 'static,
29{
30    #[error(transparent)]
31    Validation(#[from] MigrationError),
32    #[error("migration backend failed: {0}")]
33    Backend(E),
34}