`get_migrator_filepath` looks for a file `migration_dir/src/lib.rs` and returns that path if found. If `src` is not found, it will look directly in `migration_dir` for `lib.rs`. If `lib.rs` is not found, it will look for `mod.rs` instead, e.g. `migration_dir/mod.rs`. This way, `src` doesn't need to be appended in the standard case where migrations are in their own crate (with a file `lib.rs`).
(migration_dir: &str)
| 201 | /// migrations are in a submodule of another crate (with a file `mod.rs`), |
| 202 | /// `migration_dir` can point directly to that module. |
| 203 | fn get_migrator_filepath(migration_dir: &str) -> PathBuf { |
| 204 | let full_migration_dir = get_full_migration_dir(migration_dir); |
| 205 | let with_lib = full_migration_dir.join("lib.rs"); |
| 206 | match () { |
| 207 | _ if with_lib.is_file() => with_lib, |
| 208 | _ => full_migration_dir.join("mod.rs"), |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | fn update_migrator(migration_name: &str, migration_dir: &str) -> Result<(), Box<dyn Error>> { |
| 213 | let migrator_filepath = get_migrator_filepath(migration_dir); |
no test coverage detected