1use std::path::PathBuf;
2use thiserror::Error;
3
4use crate::migration::Version;
5
6pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, Error)]
9pub enum Error {
10 #[error("IO on {path}: {source}")]
11 Io {
12 path: PathBuf,
13 #[source]
14 source: std::io::Error,
15 },
16
17 #[error("invalid migration folder name `{name}`: expected YYYYMMDD_HHMMSS_<snake_case>")]
18 InvalidName { name: String },
19
20 #[error("migration `{pending}` has timestamp before highest applied `{highest_applied}`")]
21 OutOfOrder {
22 pending: Version,
23 highest_applied: Version,
24 },
25
26 #[error("migration `{version}` failed: {source}")]
27 ApplyFailed {
28 version: Version,
29 #[source]
30 source: sentinel_driver::Error,
31 },
32
33 #[error("checksum mismatch for applied migration `{version}` — file modified after apply")]
34 ChecksumDrift {
35 version: Version,
36 file: String,
37 recorded: String,
38 },
39
40 #[error("could not acquire migration lock — another process is migrating")]
41 LockBusy,
42
43 #[error("driver error: {0}")]
44 Driver(#[from] sentinel_driver::Error),
45
46 #[error("schema introspection failed: {0}")]
47 Introspect(#[from] sntl_schema::Error),
48
49 #[error("migrations directory missing or unreadable: {path}")]
50 MissingDir { path: PathBuf },
51}