sqlx_migrate_validate/
lib.rs

1//! With [sqlx] and its [sqlx::migrate!] macro it is possible to create migrations and apply them to a database.
2//! When starting an application it is important to validate that the database is in the correct state.
3//! This crate provides a way to validate that the applied migrations match the desired migrations.
4//! In combination with the [sqlx::migrate!] macro it is possible to validate that the database schema
5//! matches the migrations present in the source code at the time of compilation.
6//!
7//! While this does not ensure full compatibility between the database and the application it can help
8//! to detect issues early.
9//!
10//! Examples:
11//!
12//! ```rust,no_run
13//! use sqlx_migrate_validate::{Validate, Validator};
14//!
15//! #[tokio::main]
16//! async fn main() -> Result<(), anyhow::Error> {
17//!     let pool = sqlx::SqlitePool::connect("sqlite::memory:").await?;
18//!     let mut conn = pool.acquire().await?;
19//!
20//!     sqlx::migrate!("./tests/migrations-1")
21//!         .validate(&mut *conn)
22//!         .await?;
23//!
24//!     Ok(())
25//! }
26//! ```
27
28mod error;
29mod validate;
30
31pub use error::ValidateError;
32pub use validate::*;
33
34#[doc = include_str!("../README.md")]
35#[cfg(doctest)]
36pub struct ReadmeDoctests;