-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.go
52 lines (46 loc) · 1.11 KB
/
build.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package schema
import (
"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/google/uuid"
)
// Build holds the schema definition for the Build.
type Build struct {
ent.Schema
}
// Fields of the Build.
func (Build) Fields() []ent.Field {
return []ent.Field{
field.String("build_url").Unique().Immutable(),
field.UUID("build_uuid", uuid.UUID{}).Unique().Immutable(),
field.JSON("env", map[string]string{}).Annotations(entgql.Skip()), // NOTE: Uses custom resolver.
field.Time("timestamp").Optional(),
}
}
// Edges of the Build.
func (Build) Edges() []ent.Edge {
return []ent.Edge{
edge.To("invocations", BazelInvocation.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
// Indexes of the Build.
func (Build) Indexes() []ent.Index {
return []ent.Index{
index.Fields("env"),
}
}
// Annotations of the Build.
func (Build) Annotations() []schema.Annotation {
return []schema.Annotation{
entgql.RelayConnection(),
entgql.QueryField("findBuilds"),
}
}