Skip to content

Commit

Permalink
entc/gen/template/dialect/sql/feature: add NamedDiff method to create…
Browse files Browse the repository at this point in the history
… named versioned migration files
  • Loading branch information
masseelch committed Mar 10, 2022
1 parent 5b184f2 commit 96909d6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions entc/gen/template/dialect/sql/feature/migrate_diff.tmpl
Expand Up @@ -16,4 +16,14 @@ func (s *Schema) Diff(ctx context.Context, opts ...schema.MigrateOption) error {
}
return migrate.Diff(ctx, Tables...)
}

// NamedDiff creates a named migration file containing the statements to resolve the diff
// between the Ent schema and the connected database.
func (s *Schema) Diff(ctx context.Context, name string, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.NamedDiff(ctx, name, Tables...)
}
{{ end }}

0 comments on commit 96909d6

Please sign in to comment.