//! A library for enhacing SeaORM

#![cfg_attr(docsrs, feature(doc_cfg))]

pub use sea_orm;
pub use sea_orm_migration;

pub mod model;
pub mod orm;
pub mod schema;

/// A macro for defining a Migrator with a custom migration table while
/// avoiding typing repetition.
///
/// This macro will `mod` every migration given.
///
/// ```ignore
/// seamantic::migrations! {
///     "seaql_migrations_auth"; // table name
///     m_000001,                //
///     m_000002,                // migrations
///     m_000003,                //
/// }
/// ```
#[macro_export]
macro_rules! migrations {
	($name:literal; $($migration:ident,)*) => {
		use $crate::sea_orm::sea_query::IntoIden as _;

		$(mod $migration;)*

		/// Auto-generated migration manager
		#[automatically_derived]
		pub struct Migrator;

		#[automatically_derived]
		#[$crate::sea_orm_migration::async_trait::async_trait]
		impl $crate::sea_orm_migration::MigratorTrait for Migrator {
			fn migration_table_name() -> $crate::sea_orm::DynIden {
				$crate::sea_orm_migration::prelude::Alias::new($name).into_iden()
			}

			fn migrations() -> Vec<Box<dyn $crate::sea_orm_migration::MigrationTrait>> {
				vec![$(Box::new($migration::Migration),)*]
			}
		}
	};
}
