#![warn(missing_docs)]
mod delivery_state;
mod enqueue;
mod error;
mod finalize;
mod hydrate;
mod import;
mod lifecycle;
mod lifecycle_mutation;
mod migration;
mod page;
mod rls;
mod schema;
mod scope;
pub use error::{
ClaimError, EnqueueError, FinalizeError, ImportError, MutationError, PageError, SchemaError,
TransientKind,
};
#[allow(deprecated)]
pub use migration::{
CrateVersion, LEGACY_MIGRATION, MIGRATIONS, Migration, MigrationCompatibility,
MigrationCompatibilityError, SCHEMA_VERSION, V1_TENANT_ACTIVATE_SQL, V1_TENANT_ACTIVATE_V2_SQL,
V1_TENANT_PREPARE_SQL,
};
pub use page::SnapshotPager;
pub use rls::{RLS_PROFILE_SQL, bind_tenant};
pub use schema::check_schema;
use sqlx::PgPool;
pub use scope::{AdminDovecote, TenantDovecote};
#[derive(Clone)]
pub struct PostgresDovecote {
pool: PgPool,
}
impl PostgresDovecote {
pub fn new(pool: PgPool) -> Self {
Self { pool }
}
pub fn pool(&self) -> &PgPool {
&self.pool
}
pub fn for_tenant(&self, tenant: dovecote::TenantId) -> TenantDovecote {
TenantDovecote::new(self.pool.clone(), tenant)
}
pub fn admin(&self) -> AdminDovecote {
AdminDovecote::new(self.pool.clone())
}
pub async fn check_schema(&self) -> Result<(), SchemaError> {
check_schema(&self.pool).await
}
}