1use std::{io, path::PathBuf};
2
3use thiserror::Error;
4
5#[derive(Debug, Default, Clone, PartialEq, Eq)]
6pub struct MigrationReport {
7 pub batch: Option<u64>,
8 pub applied: Vec<u64>,
9 pub rolled_back: Vec<u64>,
10}
11
12#[derive(Debug, Error)]
13pub enum MigrationError {
14 #[error("{0}")]
15 Quex(
16 #[from]
17 #[source]
18 quex::Error,
19 ),
20 #[error("unsupported database url `{0}`")]
21 UnsupportedDatabaseUrl(String),
22 #[error("database backend `{0}` is not enabled")]
23 BackendNotEnabled(&'static str),
24 #[error("duplicate migration version `{0}` is registered")]
25 DuplicateVersion(u64),
26 #[error("missing migration registration for applied version `{0}`")]
27 MissingMigration(u64),
28 #[error("failed to read migration directory `{path}`")]
29 MigrationDirectory {
30 path: PathBuf,
31 #[source]
32 source: io::Error,
33 },
34 #[error("migration io error: {0}")]
35 Io(#[from] io::Error),
36 #[error("invalid migration filename `{0}`")]
37 InvalidMigrationFilename(PathBuf),
38 #[error("invalid migration file `{path}`: {message}")]
39 InvalidMigrationFile { path: PathBuf, message: String },
40 #[error("unsupported column type `{0}`")]
41 UnsupportedColumnType(String),
42 #[error("applied migration `{id}` checksum mismatch")]
43 ChecksumMismatch { id: u64 },
44 #[error("migration `{id}` is in failed state")]
45 FailedMigration { id: u64 },
46}
47
48pub struct ResetReport {
49 pub batches: Vec<u64>,
50 pub rolled_back: Vec<u64>,
51}