Archived
1
0
Fork 0

refac: rename variables in make migration command

This commit is contained in:
Dmitriy Pleshevskiy 2021-02-03 10:18:02 +03:00
parent 9d3d44dfa1
commit 5833e8802c

View file

@ -51,22 +51,26 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}) })
.collect(); .collect();
let new_dir_path = PathBuilder::from(config.directory_path()) let migration_dir_path = PathBuilder::from(config.directory_path())
.append(format!("{}_{}", now, migration_name)) .append(format!("{}_{}", now, migration_name))
.build(); .build();
if !new_dir_path.exists() { if !migration_dir_path.exists() {
fs::create_dir(&new_dir_path)?; fs::create_dir(&migration_dir_path)?;
} }
let upgrade_migration_path = PathBuilder::from(&new_dir_path).append("up.sql").build(); let upgrade_migration_path = PathBuilder::from(&migration_dir_path)
.append("up.sql")
.build();
if !upgrade_migration_path.exists() { if !upgrade_migration_path.exists() {
fs::write(upgrade_migration_path, "-- Your SQL goes here\n\n")?; fs::write(upgrade_migration_path, "-- Your SQL goes here\n\n")?;
} }
let down_migration_path = PathBuilder::from(&new_dir_path).append("down.sql").build(); let downgrade_migration_path = PathBuilder::from(&migration_dir_path)
if !down_migration_path.exists() { .append("down.sql")
.build();
if !downgrade_migration_path.exists() {
fs::write( fs::write(
down_migration_path, downgrade_migration_path,
"-- This file should undo anything in `up.sql`\n\n", "-- This file should undo anything in `up.sql`\n\n",
)?; )?;
} }