Skip to content

Commit

Permalink
dialect/sql/schema: add name to versioned migration files (ent#2375)
Browse files Browse the repository at this point in the history
* add name to versioned migration files

* Skip writing migration files if the plan has no changes
  • Loading branch information
imhuytq authored and gitlawr committed Apr 13, 2022
1 parent 7066ca1 commit 4ac163b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dialect/sql/schema/atlas.go
Expand Up @@ -364,7 +364,7 @@ func (m *Migrate) atDiff(ctx context.Context, conn dialect.ExecQuerier, tables .
return nil, err
}
// Plan changes.
return drv.PlanChanges(ctx, "", changes)
return drv.PlanChanges(ctx, "changes", changes)
}

type db struct{ dialect.ExecQuerier }
Expand Down
4 changes: 4 additions & 0 deletions dialect/sql/schema/migrate.go
Expand Up @@ -171,6 +171,10 @@ func (m *Migrate) Diff(ctx context.Context, tables ...*Table) error {
if err != nil {
return err
}
// Skip if the plan has no changes
if len(plan.Changes) == 0 {
return nil
}
return migrate.NewPlanner(nil, m.atlas.dir, migrate.WithFormatter(m.atlas.fmt)).WritePlan(plan)
}

Expand Down

0 comments on commit 4ac163b

Please sign in to comment.