pub trait Migration{
// Required methods
fn version() -> &'static str
where Self: Sized;
fn create_query() -> &'static str
where Self: Sized;
fn database(&self) -> &Database;
// Provided methods
fn upgrade_query() -> &'static str
where Self: Sized { ... }
fn rollback_query() -> &'static str
where Self: Sized { ... }
fn previous() -> Option<Box<dyn Migration>>
where Self: Sized { ... }
async fn validate_database<'a, C>(
&self,
connection: &'a C,
database: &Database,
) -> Result<MigrationState, Error>
where Self: Sized,
C: GeekConnection<Connection = C> + 'a { ... }
fn validate(
migrations: &mut Vec<Box<dyn Migration>>,
migration_database: &Database,
live_database: &Vec<(String, Vec<TableInfo>)>,
) -> Result<MigrationState, Error>
where Self: Sized { ... }
async fn create<'a, C>(connection: &'a C) -> Result<(), Error>
where Self: Sized,
C: GeekConnection<Connection = C> + 'a { ... }
async fn upgrade<'a, C>(connection: &'a C) -> Result<(), Error>
where Self: Sized,
C: GeekConnection<Connection = C> + 'a { ... }
async fn rollback<'a, C>(connection: &'a C) -> Result<(), Error>
where Self: Sized,
C: GeekConnection<Connection = C> + 'a { ... }
async fn migrate<'a, C>(connection: &'a C) -> Result<(), Error>
where Self: Sized,
C: GeekConnection<Connection = C> + 'a { ... }
}
Expand description
Migration trait
Required Methods§
Sourcefn create_query() -> &'static strwhere
Self: Sized,
fn create_query() -> &'static strwhere
Self: Sized,
Get the create query
Provided Methods§
Sourcefn upgrade_query() -> &'static strwhere
Self: Sized,
fn upgrade_query() -> &'static strwhere
Self: Sized,
Get the upgrade query
Sourcefn rollback_query() -> &'static strwhere
Self: Sized,
fn rollback_query() -> &'static strwhere
Self: Sized,
Get the rollback query
Sourcefn previous() -> Option<Box<dyn Migration>>where
Self: Sized,
fn previous() -> Option<Box<dyn Migration>>where
Self: Sized,
Get the previous database if it exists
Sourceasync fn validate_database<'a, C>(
&self,
connection: &'a C,
database: &Database,
) -> Result<MigrationState, Error>where
Self: Sized,
C: GeekConnection<Connection = C> + 'a,
async fn validate_database<'a, C>(
&self,
connection: &'a C,
database: &Database,
) -> Result<MigrationState, Error>where
Self: Sized,
C: GeekConnection<Connection = C> + 'a,
This function is called to validate the database schema by comparing the live database to the migration database
Sourcefn validate(
migrations: &mut Vec<Box<dyn Migration>>,
migration_database: &Database,
live_database: &Vec<(String, Vec<TableInfo>)>,
) -> Result<MigrationState, Error>where
Self: Sized,
fn validate(
migrations: &mut Vec<Box<dyn Migration>>,
migration_database: &Database,
live_database: &Vec<(String, Vec<TableInfo>)>,
) -> Result<MigrationState, Error>where
Self: Sized,
Validate the database schema is correct
Sourceasync fn create<'a, C>(connection: &'a C) -> Result<(), Error>where
Self: Sized,
C: GeekConnection<Connection = C> + 'a,
async fn create<'a, C>(connection: &'a C) -> Result<(), Error>where
Self: Sized,
C: GeekConnection<Connection = C> + 'a,
Create the database if it does not exist
Assumes the database is already created but the tables are not
Sourceasync fn upgrade<'a, C>(connection: &'a C) -> Result<(), Error>where
Self: Sized,
C: GeekConnection<Connection = C> + 'a,
async fn upgrade<'a, C>(connection: &'a C) -> Result<(), Error>where
Self: Sized,
C: GeekConnection<Connection = C> + 'a,
Migrate the previos database to the current version