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

Function run_migrate_generate

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

Source from the content-addressed store, hash-verified

127}
128
129pub fn run_migrate_generate(
130 migration_dir: &str,
131 migration_name: &str,
132 universal_time: bool,
133) -> Result<(), Box<dyn Error>> {
134 // Make sure the migration name doesn't contain any characters that
135 // are invalid module names in Rust.
136 if migration_name.contains('-') {
137 return Err(Box::new(MigrationCommandError::InvalidName(
138 "Hyphen `-` cannot be used in migration name".to_string(),
139 )));
140 }
141
142 println!("Generating new migration...");
143
144 // build new migration filename
145 const FMT: &str = "%Y%m%d_%H%M%S";
146 let formatted_now = if universal_time {
147 Utc::now().format(FMT)
148 } else {
149 Local::now().format(FMT)
150 };
151
152 let migration_name = migration_name.trim().replace(' ', "_");
153 let migration_name = format!("m{formatted_now}_{migration_name}");
154
155 create_new_migration(&migration_name, migration_dir)?;
156 update_migrator(&migration_name, migration_dir)?;
157
158 Ok(())
159}
160
161/// `get_full_migration_dir` looks for a `src` directory
162/// inside of `migration_dir` and appends that to the returned path if found.

Callers 2

run_migrate_commandFunction · 0.85
run_migrateFunction · 0.85

Calls 4

create_new_migrationFunction · 0.85
update_migratorFunction · 0.85
containsMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected