generated from datumforge/go-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
webhook_history.go
75 lines (65 loc) · 1.58 KB
/
webhook_history.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Code generated by enthistory, DO NOT EDIT.
package schema
import (
"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/field"
"entgo.io/ent/schema/index"
"github.com/datumforge/enthistory"
"github.com/datumforge/entx"
"time"
)
// WebhookHistory holds the schema definition for the WebhookHistory entity.
type WebhookHistory struct {
ent.Schema
}
// Annotations of the WebhookHistory.
func (WebhookHistory) Annotations() []schema.Annotation {
return []schema.Annotation{
entx.SchemaGenSkip(true),
entsql.Annotation{
Table: "webhook_history",
},
enthistory.Annotations{
IsHistory: true,
Exclude: true,
},
entgql.QueryField(),
entgql.RelayConnection(),
}
}
// Fields of the WebhookHistory.
func (WebhookHistory) Fields() []ent.Field {
historyFields := []ent.Field{
field.Time("history_time").
Default(time.Now).
Immutable(),
field.String("ref").
Immutable().
Optional(),
field.Enum("operation").
GoType(enthistory.OpType("")).
Immutable(),
}
// get the fields from the mixins
// we only want to include mixin fields, not edges
// so this prevents FKs back to the main tables
mixins := Webhook{}.Mixin()
for _, mixin := range mixins {
for _, field := range mixin.Fields() {
historyFields = append(historyFields, field)
}
}
original := Webhook{}
for _, field := range original.Fields() {
historyFields = append(historyFields, field)
}
return historyFields
}
func (WebhookHistory) Indexes() []ent.Index {
return []ent.Index{
index.Fields("history_time"),
}
}