lift-migration 0.1.7

Migration runtime and schema builder for lift.
Documentation
pub(crate) enum MigrationPool {
    #[cfg(feature = "sqlite")]
    Sqlite(quex::Pool),
    #[cfg(feature = "postgres")]
    Postgres(quex::Pool),
    #[cfg(feature = "mariadb")]
    Mariadb(quex::Pool),
    #[cfg(not(any(feature = "sqlite", feature = "postgres", feature = "mariadb")))]
    Disabled,
}

impl MigrationPool {
    pub(crate) fn pool(&self) -> &quex::Pool {
        match self {
            #[cfg(feature = "sqlite")]
            Self::Sqlite(pool) => pool,
            #[cfg(feature = "postgres")]
            Self::Postgres(pool) => pool,
            #[cfg(feature = "mariadb")]
            Self::Mariadb(pool) => pool,
            #[cfg(not(any(feature = "sqlite", feature = "postgres", feature = "mariadb")))]
            Self::Disabled => panic!("migration pool backend is not enabled"),
        }
    }

    #[allow(dead_code)]
    pub(crate) fn backend_name(&self) -> &'static str {
        match self {
            #[cfg(feature = "sqlite")]
            Self::Sqlite(_) => "sqlite",
            #[cfg(feature = "postgres")]
            Self::Postgres(_) => "postgres",
            #[cfg(feature = "mariadb")]
            Self::Mariadb(_) => "mariadb",
            #[cfg(not(any(feature = "sqlite", feature = "postgres", feature = "mariadb")))]
            Self::Disabled => "disabled",
        }
    }

    pub(crate) fn supports_clean_failed_retry(&self) -> bool {
        match self {
            #[cfg(feature = "sqlite")]
            Self::Sqlite(_) => true,
            #[cfg(feature = "postgres")]
            Self::Postgres(_) => true,
            #[cfg(feature = "mariadb")]
            Self::Mariadb(_) => false,
            #[cfg(not(any(feature = "sqlite", feature = "postgres", feature = "mariadb")))]
            Self::Disabled => false,
        }
    }
}