use async_trait::async_trait;
use crate::connection::DatabaseConnection;
#[async_trait]
pub trait Schema {
async fn create_table(connection: &impl DatabaseConnection) -> crate::Result<()>;
async fn drop_table(connection: &impl DatabaseConnection) -> crate::Result<()>;
async fn truncate_table(connection: &impl DatabaseConnection) -> crate::Result<()>;
async fn table_exists(connection: &impl DatabaseConnection) -> crate::Result<bool>;
async fn create_table_if_not_exists(connection: &impl DatabaseConnection) -> crate::Result<()> {
if !Self::table_exists(connection).await? {
Self::create_table(connection).await?;
}
Ok(())
}
}