Skip to content

Commit 81983a8

Browse files
committed
doc: Add information on the required structure of the migration scripts
1 parent 1a9e0d9 commit 81983a8

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

sqlx-core/src/migrate/migrator.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl Migrator {
2727
/// # })
2828
/// # }
2929
/// ```
30+
/// See [MigrationSource] for details on structure of the `./migrations` directory.
3031
pub async fn new<'s, S>(source: S) -> Result<Self, MigrateError>
3132
where
3233
S: MigrationSource<'s>,

sqlx-core/src/migrate/source.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ pub trait MigrationSource<'s>: Debug {
1111
fn resolve(self) -> BoxFuture<'s, Result<Vec<Migration>, BoxDynError>>;
1212
}
1313

14+
/// Implementation of the `MigrationSource` for [std::path::Path].
15+
///
16+
/// The path has to point to a directory, which contains the migration SQL scripts. All these
17+
/// scripts must be stored in files with names using the format `<VERSION>_<DESCRIPTION>.sql`,
18+
/// where `<VERSION>` is a string that can be parsed into `i64` and its value is greater than zero,
19+
/// and `<DESCRIPTION>` is a string.
1420
impl<'s> MigrationSource<'s> for &'s Path {
1521
fn resolve(self) -> BoxFuture<'s, Result<Vec<Migration>, BoxDynError>> {
1622
Box::pin(async move {

0 commit comments

Comments
 (0)