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:
Ariel Mashraki
2021-04-29 22:25:27 +03:00
committed by GitHub
parent b3c437f936
commit 1635a66cdd

View File

@@ -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
}