Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI command to generate a new migration #656

Merged
merged 18 commits into from
May 9, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(cli): harden regex against extra spaces
As suggested by @billy1624 in the review of #656.
  • Loading branch information
viktorbahr committed May 1, 2022
commit 0e75ac0388bb90ee3aec4822ab5feb9cce27570f
2 changes: 1 addition & 1 deletion sea-orm-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn update_migrator(migration_name: &str, migration_dir: &str) -> Result<(), Box<
let mut migrator_file = fs::File::create(&migrator_filepath)?;

// find existing mod declarations, add new line
let mod_regex = Regex::new(r"mod (?P<name>m\d{8}_\d{6}_\w+);")?;
let mod_regex = Regex::new(r"mod\s+(?P<name>m\d{8}_\d{6}_\w+);")?;
let mods: Vec<_> = mod_regex.captures_iter(&migrator_content).collect();
let mods_end = mods.last().unwrap().get(0).unwrap().end() + 1;
updated_migrator_content.insert_str(mods_end, format!("mod {};\n", migration_name).as_str());
Expand Down