diff --git a/entc/gen/template/dialect/sql/feature/migrate_diff.tmpl b/entc/gen/template/dialect/sql/feature/migrate_diff.tmpl index df879f873b..6657b1e0fc 100644 --- a/entc/gen/template/dialect/sql/feature/migrate_diff.tmpl +++ b/entc/gen/template/dialect/sql/feature/migrate_diff.tmpl @@ -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 }} \ No newline at end of file