//! rok-orm-migrate — Database migration runner for the rok ecosystem.
//!
//! # Architecture
//!
//! Migrations come from one or more **sources**:
//!
//! - [`EmbeddedMigrations`] — SQL compiled into the binary (`include_str!`).
//!   Framework crates (rok-auth, rok-lock, …) expose a
//!   `pub fn migrations() -> EmbeddedMigrations` so callers can register them.
//!
//! - [`FileSource`] — reads `*.sql` files from a directory at startup.
//!   Application developers point this at their `migrations/` folder.
//!
//! - [`Migration`] — async schema-builder trait for typed Rust migrations.
//!   Preferred for application migrations; generated by `rok make:migration`.
//!
//! The [`MigrationRunner`] accepts any combination of sources and inline
//! migrations (registered with `.source()` or `.migration()`).
//!
//! # Quick start — schema-builder migrations
//!
//! ```rust,ignore
//! use rok_orm_migrate::{Migration, MigrationRunner, SchemaExecutor};
//! use async_trait::async_trait;
//!
//! pub struct CreateUsersTable;
//!
//! #[async_trait]
//! impl Migration for CreateUsersTable {
//!     fn name(&self) -> &str { "2026_05_18_000001_create_users_table" }
//!
//!     async fn up(&self, schema: &SchemaExecutor) -> anyhow::Result<()> {
//!         schema.create("users", |t| {
//!             t.id();
//!             t.string("email").not_null().unique();
//!             t.string("name").not_null();
//!             t.timestamps();
//!         }).await
//!     }
//!
//!     async fn down(&self, schema: &SchemaExecutor) -> anyhow::Result<()> {
//!         schema.drop_table_if_exists("users").await
//!     }
//! }
//!
//! MigrationRunner::new(pool)
//!     .source(rok_auth::migrations())   // crate-owned SQL tables
//!     .migration(CreateUsersTable)      // schema-builder migration
//!     .run()
//!     .await?;
//! ```
//!
//! # SQL file migrations (legacy / simple cases)
//!
//! ```rust,ignore
//! use rok_orm_migrate::{MigrationRunner, FileSource};
//!
//! MigrationRunner::new(pool)
//!     .source(FileSource::new("./database/migrations"))
//!     .run()
//!     .await?;
//! ```

pub mod migration;
pub mod schema;
pub mod source;
pub mod table;

#[cfg(feature = "postgres")]
pub mod runner;

// ── Core traits ───────────────────────────────────────────────────────────────

/// Async schema-builder migration trait (preferred for application migrations).
#[cfg(feature = "postgres")]
pub use migration::Migration;

/// Sync raw-SQL migration trait (used by embedded and file-based sources).
pub use migration::RawMigration;

// ── Schema builders ───────────────────────────────────────────────────────────

pub use schema::{AlterTableBuilder, CreateTableBuilder, DropTableBuilder, Schema};

/// Live database executor — passed to [`Migration::up`] and [`Migration::down`].
#[cfg(feature = "postgres")]
pub use schema::SchemaExecutor;

// ── Sources and runner ────────────────────────────────────────────────────────

pub use source::{EmbeddedMigration, EmbeddedMigrations, FileSource, MigrationSource};
pub use table::{AlterColumnBuilder, ColumnBuilder, TableBuilder};

#[cfg(feature = "postgres")]
pub use runner::MigrationRunner;
