@@ -7,16 +7,24 @@ use std::borrow::Cow;
7
7
use std:: fmt:: Debug ;
8
8
use std:: path:: { Path , PathBuf } ;
9
9
10
+ /// In the default implementation, a MigrationSource is a directory which
11
+ /// contains the migration SQL scripts. All these scripts must be stored in
12
+ /// files with names using the format `<VERSION>_<DESCRIPTION>.sql`, where
13
+ /// `<VERSION>` is a string that can be parsed into `i64` and its value is
14
+ /// greater than zero, and `<DESCRIPTION>` is a string.
15
+ ///
16
+ /// Files that don't match this format are silently ignored.
17
+ ///
18
+ /// You can create a new empty migration script using sqlx-cli:
19
+ /// `sqlx migrate add <DESCRIPTION>`.
20
+ ///
21
+ /// Note that migrations for each database are tracked using the
22
+ /// `_sqlx_migrations` table (stored in the database). If a migration's hash
23
+ /// changes and it has already been run, this will cause an error.
10
24
pub trait MigrationSource < ' s > : Debug {
11
25
fn resolve ( self ) -> BoxFuture < ' s , Result < Vec < Migration > , BoxDynError > > ;
12
26
}
13
27
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.
20
28
impl < ' s > MigrationSource < ' s > for & ' s Path {
21
29
fn resolve ( self ) -> BoxFuture < ' s , Result < Vec < Migration > , BoxDynError > > {
22
30
Box :: pin ( async move {
0 commit comments