arcadedb_migrate/lib.rs
1//! Schema migration manager for ArcadeDB. Declarative sync
2//! (diff desired `.sql` schema vs. live `schema:types`, apply reconciliation
3//! DDL) + sequential override migrations for renames/backfills the diff can't
4//! infer + a seed phase. State recorded in the database.
5//!
6//! The complete model — directory layout, two-phase apply, the four integrity
7//! layers, baseline rules, and the engine realities — lives in
8//! one place: `docs/migration-model.md` (repo root). The module docs below
9//! cover their own slice and link outward rather than re-explaining.
10//!
11//! Overrides apply in two phases (copy-in-explicit-transaction with in-tx
12//! verification, then journaled destructive/swap statements) because ArcadeDB
13//! auto-commits DDL — see [`migrator`] for the model.
14//!
15//! This crate depends on [`arcadedb_protocol`] for the gRPC wire layer. The
16//! `migrate` binary (`cargo run -p arcadedb-migrate --bin arcadedb-migrate`)
17//! is a generic entry point any app can invoke with its schema directory.
18//!
19//! ## Quick start
20//!
21//! ```no_run
22//! # async fn run() -> arcadedb_migrate::Result<()> {
23//! use arcadedb_migrate::schema::{Migrator, DropStrategy};
24//! use arcadedb_protocol::ArcadeDbClient;
25//!
26//! let client = ArcadeDbClient::connect("127.0.0.1:50051", "root", "password", "mydb").await?;
27//! let migrator = Migrator::new(client, "mydb").await?;
28//!
29//! // Parse database/schema_arcadedb/*.sql + seed/*.sql, diff against the live
30//! // DB, apply.
31//! let report = migrator.sync_dir("database/schema_arcadedb", DropStrategy::Never).await?;
32//! println!("{report}");
33//! # Ok(()) }
34//! ```
35
36pub mod cli;
37pub mod error;
38pub mod migrator;
39pub mod schema;
40
41pub use error::{MigrateError, Result};