MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / get_migrator_filepath

Function get_migrator_filepath

sea-orm-cli/src/commands/migrate.rs:203–210  ·  view source on GitHub ↗

`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)

Source from the content-addressed store, hash-verified

201/// migrations are in a submodule of another crate (with a file `mod.rs`),
202/// `migration_dir` can point directly to that module.
203fn 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
212fn update_migrator(migration_name: &str, migration_dir: &str) -> Result<(), Box<dyn Error>> {
213 let migrator_filepath = get_migrator_filepath(migration_dir);

Callers 1

update_migratorFunction · 0.85

Calls 2

get_full_migration_dirFunction · 0.85
joinMethod · 0.80

Tested by

no test coverage detected