dialect/entsql: add Skip annotation (#4156)

This commit is contained in:
Ariel Mashraki
2024-07-26 23:03:21 +03:00
committed by GitHub
parent be9aafdc49
commit 5cd2ede22d
3 changed files with 28 additions and 4 deletions

View File

@@ -149,6 +149,15 @@ type Annotation struct {
// }
//
Checks map[string]string `json:"checks,omitempty"`
// Skip indicates that the field or the schema is skipped/ignored during
// migration (e.g., defined externally).
//
// entsql.Annotation{
// Skip: true,
// }
//
Skip bool `json:"skip,omitempty"`
}
// Name describes the annotation name.
@@ -217,6 +226,12 @@ func Checks(c map[string]string) *Annotation {
}
}
// Skip indicates that the field or the schema is skipped/ignored during
// migration (e.g., defined externally).
func Skip() *Annotation {
return &Annotation{Skip: true}
}
// Default specifies a literal default value of a column. Note that using
// this option overrides the default behavior of the code-generation.
//
@@ -358,6 +373,9 @@ func (a Annotation) Merge(other schema.Annotation) schema.Annotation {
a.Checks[name] = check
}
}
if ant.Skip {
a.Skip = true
}
return a
}