Add OnDelete annotation to each edge

This commit is contained in:
Vojtěch Káně
2021-04-21 12:10:28 +02:00
parent 52f2e238e1
commit 1e31b770ca
5 changed files with 37 additions and 8 deletions

View File

@@ -2,6 +2,7 @@ package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
@@ -29,6 +30,9 @@ func (Choice) Edges() []ent.Edge {
Ref("choices").
Unique().
Required(),
edge.To("answers", Answer.Type),
edge.To("answers", Answer.Type).
Annotations(entsql.Annotation{
OnDelete: entsql.Restrict,
}),
}
}