toolu_orm_cli/migrate/
error.rs1use thiserror::Error;
4use toolu_orm_connection::DbError;
5
6#[derive(Debug, Error)]
7pub enum MigrateError {
8 #[error("database error: {0}")]
9 Database(String),
10
11 #[error("failed to read migrations directory: {0}")]
12 ReadDir(String),
13
14 #[error("failed to read migration file: {0}")]
15 ReadFile(String),
16
17 #[error("migration {file} has been modified (expected {expected}, got {actual})")]
18 HashMismatch {
19 file: String,
20 expected: String,
21 actual: String,
22 },
23
24 #[error("no journal entry for migration(s): {0}")]
27 NotInJournal(String),
28
29 #[error("duplicate migration name(s) in the embedded list: {0}")]
32 DuplicateMigration(String),
33}
34
35pub(crate) fn map_db(err: &DbError) -> MigrateError {
36 MigrateError::Database(err.to_string())
37}