Skip to content

Commit

Permalink
docs: document what happens with extra_check
Browse files Browse the repository at this point in the history
Explicitly document that the `extra_check` feature of rusqlite will
cause errors to be returned if a migration returns anything. This is, I
think, why people use that feature.

Also document what happens on rusqlite errors during statement
execution.

Fixes #134
  • Loading branch information
cljoly committed Aug 4, 2024
1 parent 73f36e2 commit 66539d7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions rusqlite_migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,30 @@ impl<'m> Migrations<'m> {
/// # Errors
///
/// Returns [`Error::MigrationDefinition`] if no migration is defined.
///
/// Returns [`Error::RusqliteError`] if rusqlite returns an error when executing a migration
/// statement. Note that this immediatley stops applying migrations.
/// ```rust
/// # use rusqlite_migration::{Migrations, M};
/// let mut conn = rusqlite::Connection::open_in_memory().unwrap();
///
/// let migrations = Migrations::new(vec![
/// M::up("CREATE TABLE t1 (c);"),
/// M::up("SYNTAX ERROR"), // This won’t be applied
/// M::up("CREATE TABLE t2 (c);"), // This won’t be applied either because the migration above
/// // failed
/// ]);
///
/// assert!(matches!(
/// migrations.to_latest(&mut conn),
/// Err(rusqlite_migration::Error::RusqliteError {
/// query: _,
/// err: rusqlite::Error::SqliteFailure(_, _),
/// })
/// ));
/// ```
/// If rusqlite `extra_check` feature is enabled, any migration that returns a value will error
/// and no further migrations will be applied.
pub fn to_latest(&self, conn: &mut Connection) -> Result<()> {
let v_max = self.max_schema_version();
match v_max {
Expand Down

0 comments on commit 66539d7

Please sign in to comment.