mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/sql/schema: normalize ent/schema (desired state) on replay mode (#3100)
This commit is contained in:
@@ -33,7 +33,7 @@ var (
|
||||
|
||||
func init() {
|
||||
UsersTable.Annotation = &entsql.Annotation{
|
||||
Check: "(`age` > 0)",
|
||||
Check: "age > 0",
|
||||
}
|
||||
UsersTable.Annotation.Checks = map[string]string{
|
||||
"name_not_empty": "name <> ''",
|
||||
|
||||
@@ -23,9 +23,10 @@ func (User) Fields() []ent.Field {
|
||||
// Annotations of the User.
|
||||
func (User) Annotations() []schema.Annotation {
|
||||
return []schema.Annotation{
|
||||
// Unnamed check constraints should be identical to their definition in the
|
||||
// database (i.e. normalized). See: https://atlasgo.io/concepts/dev-database.
|
||||
entsql.Check("(`age` > 0)"),
|
||||
// In case schema.ModeInspect is used without a dev-database, unnamed check constraints
|
||||
// should be normalized (i.e. identical to their definition in the database). In this
|
||||
// case, it is entsql.Check("(`age` > 0)"). See: https://atlasgo.io/concepts/dev-database.
|
||||
entsql.Check("age > 0"),
|
||||
|
||||
// Named check constraints are compared by their name.
|
||||
// Thus, the definition does not need to be normalized.
|
||||
|
||||
Reference in New Issue
Block a user