pub trait MigrationSource<'s>: Debug {
// Required method
fn resolve(
self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Migration>, Box<dyn Error + Sync + Send>>> + Send + 's>>;
}
Expand description
In the default implementation, a MigrationSource is a directory which
contains the migration SQL scripts. All these scripts must be stored in
files with names using the format <VERSION>_<DESCRIPTION>.sql
, where
<VERSION>
is a string that can be parsed into i64
and its value is
greater than zero, and <DESCRIPTION>
is a string.
Files that don’t match this format are silently ignored.
You can create a new empty migration script using sqlx-cli:
sqlx migrate add <DESCRIPTION>
.
Note that migrations for each database are tracked using the
_sqlx_migrations
table (stored in the database). If a migration’s hash
changes and it has already been run, this will cause an error.