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

Function create_new_migration

sea-orm-cli/src/commands/migrate.rs:179–189  ·  view source on GitHub ↗
(migration_name: &str, migration_dir: &str)

Source from the content-addressed store, hash-verified

177}
178
179fn create_new_migration(migration_name: &str, migration_dir: &str) -> Result<(), Box<dyn Error>> {
180 let migration_filepath =
181 get_full_migration_dir(migration_dir).join(format!("{}.rs", &migration_name));
182 println!("Creating migration file `{}`", migration_filepath.display());
183 // TODO: make OS agnostic
184 let migration_template =
185 include_str!("../../template/migration/src/m20220101_000001_create_table.rs");
186 let mut migration_file = fs::File::create(migration_filepath)?;
187 migration_file.write_all(migration_template.as_bytes())?;
188 Ok(())
189}
190
191/// `get_migrator_filepath` looks for a file `migration_dir/src/lib.rs`
192/// and returns that path if found.

Callers 2

run_migrate_generateFunction · 0.85

Calls 3

get_full_migration_dirFunction · 0.85
joinMethod · 0.80
createFunction · 0.50

Tested by 1