mirror of
https://github.com/ent/ent.git
synced 2026-03-05 19:35:23 +03:00
schema/field: support annotating fields as deprecated (#4132)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user