migratrom 0.2.0

Declarative, self-verifying database migrations (core engine).
Documentation
//! Shared helpers for operation builders.
//!
//! The helpers keep builder files focused on SQL shape while centralizing
//! construction of checks, execute steps, and dialect capability errors.

use crate::error::{MigratromError, Result};
use crate::sql::SqlDialect;
use crate::types::{Check, ExecuteStep};

/// Build a boolean probe.
pub(crate) fn check(description: impl Into<String>, sql: impl Into<String>) -> Check {
    Check::new(description, sql)
}

/// Build an execute step.
pub(crate) fn step(description: impl Into<String>, sql: impl Into<String>) -> ExecuteStep {
    ExecuteStep::new(description, sql)
}

/// Error out when the dialect lacks a capability the builder needs.
pub(crate) fn require_capability(
    dialect: &dyn SqlDialect,
    supported: bool,
    feature: &str,
) -> Result<()> {
    if supported {
        Ok(())
    } else {
        Err(MigratromError::Unsupported {
            feature: feature.to_string(),
            dialect: dialect.name().to_string(),
        })
    }
}