mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/entsql: add check constraint annotation (#1519)
* added Check constraint annotation * Update dialect/entsql/annotation.go Co-authored-by: davebehr1 <davebehr1@gmail.com>
This commit is contained in:
@@ -86,6 +86,14 @@ type Annotation struct {
|
||||
// }
|
||||
//
|
||||
OnDelete ReferenceOption `json:"on_delete,omitempty"`
|
||||
|
||||
// Check allows injecting custom "DDL" for setting the "CHECK" clause in "CREATE TABLE".
|
||||
//
|
||||
// entsql.Annotation{
|
||||
// Check: "age < 10",
|
||||
// }
|
||||
//
|
||||
Check string `json:"check,omitempty"`
|
||||
}
|
||||
|
||||
// Name describes the annotation name.
|
||||
@@ -127,6 +135,9 @@ func (a Annotation) Merge(other schema.Annotation) schema.Annotation {
|
||||
if s := ant.OnDelete; s != "" {
|
||||
a.OnDelete = s
|
||||
}
|
||||
if s := ant.Check; s != "" {
|
||||
a.Check = s
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user