Skip to content

Commit 630f7eb

Browse files
committed
gnd: Only print about migrations if there are actually any
1 parent 85af0e6 commit 630f7eb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

gnd/src/migrations/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ fn all_migrations() -> Vec<Box<dyn Migration>> {
7272
/// Migrations are applied in order, with each migration checking if it should
7373
/// be applied before making changes. The manifest file is modified in-place.
7474
pub fn apply_migrations(manifest_path: &Path) -> Result<()> {
75-
step(Step::Load, "Apply migrations");
75+
let mut apply_printed = false;
76+
let mut print_apply = || {
77+
if !apply_printed {
78+
step(Step::Generate, "Applying migrations");
79+
apply_printed = true;
80+
}
81+
};
7682

7783
let source_dir = crate::manifest::manifest_dir(manifest_path);
7884

@@ -84,16 +90,18 @@ pub fn apply_migrations(manifest_path: &Path) -> Result<()> {
8490
for migration in all_migrations() {
8591
match migration.check(&ctx)? {
8692
MigrationCheck::ShouldApply => {
93+
print_apply();
8794
step(
8895
Step::Generate,
8996
&format!("Apply migration: {}", migration.name()),
9097
);
9198
migration.apply(&ctx)?;
9299
}
93100
MigrationCheck::Skip => {
94-
step(Step::Skip, &format!("Skip migration: {}", migration.name()));
101+
// No need to bother the user
95102
}
96103
MigrationCheck::SkipWithReason(reason) => {
104+
print_apply();
97105
step(
98106
Step::Skip,
99107
&format!("Skip migration: {} ({})", migration.name(), reason),

0 commit comments

Comments
 (0)