schema/field: support annotating fields as deprecated (#4132)

This commit is contained in:
Ariel Mashraki
2024-07-10 15:55:37 +03:00
committed by GitHub
parent db2088c34a
commit 7871b82e81
14 changed files with 385 additions and 65 deletions

View File

@@ -702,6 +702,22 @@ func (User) Fields() []ent.Field {
}
```
## Deprecated Fields
The `Deprecated` method can be used to mark a field as deprecated. Deprecated fields are not
selected by default in queries, and their struct fields are annotated as `Deprecated` in the
generated code.
```go
// Fields of the user.
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("name").
Deprecated("use `full_name` instead"),
}
}
```
## Storage Key
Custom storage name can be configured using the `StorageKey` method.