forked from torrust/torrust-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.rs
More file actions
32 lines (29 loc) · 1008 Bytes
/
Copy pathschema.rs
File metadata and controls
32 lines (29 loc) · 1008 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//! The [`SchemaMigrator`] trait — schema management context.
use async_trait::async_trait;
use mockall::automock;
use super::super::error::Error;
/// Trait covering schema lifecycle operations for a database driver.
///
/// Implementors are responsible for creating and dropping the full set of
/// database tables used by the tracker.
#[async_trait]
#[allow(clippy::extra_unused_lifetimes)]
#[automock]
pub trait SchemaMigrator: Sync + Send {
/// Creates the necessary database tables.
///
/// The SQL queries for table creation are hardcoded in the trait implementation.
///
/// # Errors
///
/// Returns an [`Error`] if the tables cannot be created.
async fn create_database_tables(&self) -> Result<(), Error>;
/// Drops the database tables.
///
/// This operation removes the persistent schema.
///
/// # Errors
///
/// Returns an [`Error`] if the tables cannot be dropped.
async fn drop_database_tables(&self) -> Result<(), Error>;
}