Skip to main content

gaman/
lib.rs

1//! Native database execution, filesystem integration, and CLI APIs for Gaman.
2//!
3//! The root crate connects the database-I/O-free `gaman-core` lifecycle to
4//! migration sources, live database executors, inspection, and user-facing
5//! commands. Offline-only builds re-export the core planning API.
6
7#[cfg(all(not(feature = "native"), not(feature = "offline")))]
8compile_error!("enable either the 'offline' feature or a native feature set");
9
10#[cfg(all(feature = "offline", not(feature = "native")))]
11pub use gaman_core::*;
12
13#[cfg(all(feature = "offline", not(feature = "native")))]
14pub mod core {
15    pub use gaman_core::clarifier::{
16        Answer, Clarification, ClarificationKind, ClarificationMessage, ClarificationOption,
17        Decision, OptionAction, PromptEngine, Severity, clarification_message,
18    };
19    pub use gaman_core::dialects::{Dialect, DialectError};
20    pub use gaman_core::graphs::{GraphError, MigrationGraph, MigrationNode};
21    pub use gaman_core::{EmbeddedMigrations, Migration, OfflineError, OfflinePlanner};
22}
23
24#[cfg(feature = "cli")]
25pub mod cli;
26#[cfg(feature = "native")]
27pub(crate) mod conf;
28#[cfg(feature = "db")]
29pub(crate) mod environment;
30#[cfg(feature = "db")]
31pub(crate) mod executor;
32#[cfg(feature = "fs")]
33mod migration_store;
34#[cfg(feature = "cli")]
35pub(crate) mod prompter;
36#[cfg(feature = "db")]
37pub mod runner_factory;
38#[cfg(feature = "native")]
39pub mod schema_file;
40
41#[cfg(feature = "native")]
42pub mod parsers {
43    pub use gaman_core::parsers::*;
44}
45
46/// Semantic drift reports, contracts, comparison, and formatting.
47#[cfg(feature = "native")]
48pub mod drift {
49    pub use gaman_core::drift::*;
50}
51
52// Everyday API.
53#[cfg(feature = "native")]
54pub use conf::{Config, ConfigError, TlsMode};
55#[cfg(feature = "db")]
56pub use gaman_core::{
57    ApplyCommand, COMMAND_PROTOCOL_VERSION, Command as RunnerCommand, CommandDiagnostic,
58    CommandEnvelope, CommandError as RunnerCommandError, CommandFailure, CommandRequest,
59    CommandResponse, CommandResult, DatabaseTrackingStore, DiagnosticCode, Executor, ExecutorError,
60    InspectionError, MakeCommand, MakeResult, MigrationArtifact, MigrationCatalog, MigrationEngine,
61    MigrationMovement, MigrationRunner, MigrationStatus, RepairOptions, RepairReport,
62    SchemaCheckFailure, SchemaCheckInput, SchemaCheckResult, SchemaCheckStatus, SchemaInspector,
63    SqlInput, TrackingStore,
64};
65#[cfg(feature = "native")]
66pub use gaman_core::{EmbeddedMigrations, EngineError, Migration, OfflineError, OfflinePlanner};
67
68/// Schema types and builders.
69#[cfg(feature = "native")]
70pub mod schema {
71    pub use gaman_core::column_type::{ColumnDesc, ColumnType};
72    pub use gaman_core::entity_selector::EntityDependency;
73    pub use gaman_core::operations::Operation;
74    pub use gaman_core::parsers::ParseError;
75    pub use gaman_core::states::{
76        Column, ColumnBuilder, ColumnRef, Constraint, ConstraintInput, EnumDef, EnumInput,
77        ExtensionDef, ExtensionInput, ForeignKey, FunctionBuilder, FunctionDef, FunctionIdentity,
78        FunctionInput, FunctionParameter, GeneratedStorage, Index, IndexInput, InputSchema,
79        IntoTable, PostgresRangePartition, PostgresRangePartitioning, PrimaryKey, ReplayError,
80        Schema, SchemaBuilder, SchemaLoadError, SchemaValidationError, Table, TableBuilder,
81        TableInput, TriggerDef, TriggerEvent, TriggerInput, TriggerScope, TriggerTiming, ViewDef,
82        ViewInput, Volatility, is_volatile, schema_qualified_key,
83    };
84}
85
86/// Lower-level APIs for custom executors, sources, and integration work.
87#[cfg(feature = "native")]
88pub mod core {
89    #[cfg(feature = "db")]
90    pub use crate::environment::{Environment, EnvironmentError, EnvironmentExecutor};
91    #[cfg(any(feature = "mysql", feature = "mariadb"))]
92    pub use crate::executor::MysqlFamilyExecutor;
93    #[cfg(feature = "postgres")]
94    pub use crate::executor::PostgresExecutor;
95    #[cfg(feature = "sqlite")]
96    pub use crate::executor::SqliteExecutor;
97    #[cfg(feature = "db")]
98    pub use gaman_core::clarifier::{
99        Answer, Clarification, ClarificationKind, ClarificationMessage, ClarificationOption,
100        Decision, OptionAction, PromptEngine, Severity, clarification_message,
101    };
102    pub use gaman_core::dialects::{Dialect, DialectError};
103    #[cfg(feature = "db")]
104    pub use gaman_core::drift::{DriftFinding, VerificationReport};
105    pub use gaman_core::graphs::{GraphError, MigrationGraph, MigrationNode};
106    pub use gaman_core::sql_plan::{SqlPlanError, SqlPlanRenderer};
107    pub use gaman_core::{
108        BoxFuture, DatabaseTrackingStore, Executor, ExecutorError, MigrationEngine, MigrationStore,
109        OfflineError, OfflinePlanner, SchemaInspector, StoreError, TRACKING_TABLE, TrackingStore,
110    };
111}