aboutsummaryrefslogtreecommitdiff
path: root/src/cli
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-06-30 16:31:21 -0600
committerMelody Horn <melody@boringcactus.com>2021-06-30 16:31:21 -0600
commitbc874c9d1363d3bf8865ea7a629eb976e23386b3 (patch)
tree17327e9d10acbb198b915592391ef9446c5b4c37 /src/cli
parenta4f6e7af6576744e238ecafda826cbe602c23db5 (diff)
downloadtosin-bc874c9d1363d3bf8865ea7a629eb976e23386b3.tar.gz
tosin-bc874c9d1363d3bf8865ea7a629eb976e23386b3.zip
use the actual path to the app dir for make_migrations
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/make_migrations.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/cli/make_migrations.rs b/src/cli/make_migrations.rs
index e0653b6..d4ddcbf 100644
--- a/src/cli/make_migrations.rs
+++ b/src/cli/make_migrations.rs
@@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::fs;
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use quote::{quote, ToTokens};
use structopt::StructOpt;
@@ -131,12 +131,11 @@ impl MakeMigrations {
};
let file_name = format!("m_{:04}_{}.rs", next_id, name);
let file_text = file.into_token_stream().to_string();
- let app_folder = app.name.split("::").skip(1).collect::<PathBuf>();
- // TODO don't explode if running in a weird place
- let file_path = PathBuf::from("src")
- .join(app_folder)
- .join("migrations")
- .join(file_name);
+ let app_mod_rs = Path::new(app.mod_rs_path);
+ let app_folder = app_mod_rs
+ .parent()
+ .expect("app mod.rs lives at filesystem root???");
+ let file_path = app_folder.join("migrations").join(file_name);
println!("Saving migration to {}...", file_path.display());
fs::write(file_path, file_text).unwrap();
// TODO cargo fmt