Fix [cli] cargo publish failed
This commit is contained in:
parent
cd98137ad0
commit
0a06892aac
@ -200,20 +200,23 @@ fn run_migrate_command(matches: &ArgMatches<'_>) -> Result<(), Box<dyn Error>> {
|
|||||||
println!("Initializing migration directory...");
|
println!("Initializing migration directory...");
|
||||||
macro_rules! write_file {
|
macro_rules! write_file {
|
||||||
($filename: literal) => {
|
($filename: literal) => {
|
||||||
|
write_file!($filename, $filename);
|
||||||
|
};
|
||||||
|
($filename: literal, $template: literal) => {
|
||||||
let filepath = [&migration_dir, $filename].join("");
|
let filepath = [&migration_dir, $filename].join("");
|
||||||
println!("Creating file `{}`", filepath);
|
println!("Creating file `{}`", filepath);
|
||||||
let path = Path::new(&filepath);
|
let path = Path::new(&filepath);
|
||||||
let prefix = path.parent().unwrap();
|
let prefix = path.parent().unwrap();
|
||||||
fs::create_dir_all(prefix).unwrap();
|
fs::create_dir_all(prefix).unwrap();
|
||||||
let mut file = fs::File::create(path)?;
|
let mut file = fs::File::create(path)?;
|
||||||
let content = include_str!(concat!("../template/migration/", $filename));
|
let content = include_str!(concat!("../template/migration/", $template));
|
||||||
file.write_all(content.as_bytes())?;
|
file.write_all(content.as_bytes())?;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
write_file!("src/lib.rs");
|
write_file!("src/lib.rs");
|
||||||
write_file!("src/m20220101_000001_create_table.rs");
|
write_file!("src/m20220101_000001_create_table.rs");
|
||||||
write_file!("src/main.rs");
|
write_file!("src/main.rs");
|
||||||
write_file!("Cargo.toml");
|
write_file!("Cargo.toml", "_Cargo.toml");
|
||||||
write_file!("README.md");
|
write_file!("README.md");
|
||||||
println!("Done!");
|
println!("Done!");
|
||||||
// Early exit!
|
// Early exit!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user