From 1635a66cdddf252d8ebaac40964d965b7389f440 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki <7413593+a8m@users.noreply.github.com> Date: Thu, 29 Apr 2021 22:25:27 +0300 Subject: [PATCH] dialect/entsql: add check constraint annotation (#1519) * added Check constraint annotation * Update dialect/entsql/annotation.go Co-authored-by: davebehr1 --- dialect/entsql/annotation.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dialect/entsql/annotation.go b/dialect/entsql/annotation.go index ee8f2c130..85751b038 100644 --- a/dialect/entsql/annotation.go +++ b/dialect/entsql/annotation.go @@ -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 }