-
Notifications
You must be signed in to change notification settings - Fork 0
/
order_history.go
78 lines (72 loc) · 1.57 KB
/
order_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
76
77
78
package schema
import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
"github.com/google/uuid"
)
// OrderHistory holds the schema definition for the OrderHistory entity.
type OrderHistory struct {
ent.Schema
}
// Annotations of the OrderHistory.
func (OrderHistory) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "order_history"},
}
}
// Fields of the OrderHistory.
func (OrderHistory) Fields() []ent.Field {
return []ent.Field{
field.UUID("id", uuid.UUID{}).
Default(uuid.New).
Immutable(),
field.UUID("order_id", uuid.UUID{}).
Immutable(),
field.UUID("person_id", uuid.UUID{}).
Immutable(),
field.Int("old_status_code").
Optional().
Nillable().
Immutable(),
field.Int("new_status_code").
Optional().
Nillable().
Immutable(),
field.String("description").
Optional().
Nillable().
Immutable(),
}
}
// Edges of the OrderHistory.
func (OrderHistory) Edges() []ent.Edge {
return []ent.Edge{
edge.To("order", Order.Type).
Field("order_id").
Unique().
Required().
Immutable(),
edge.To("person", Person.Type).
Field("person_id").
Unique().
Required().
Immutable(),
edge.To("old_status", OrderStatusCode.Type).
Field("old_status_code").
Unique().
Immutable(),
edge.To("new_status", OrderStatusCode.Type).
Field("new_status_code").
Unique().
Immutable(),
}
}
// Mixin of the OrderHistory.
func (OrderHistory) Mixin() []ent.Mixin {
return []ent.Mixin{
CreationTimeMixin{},
}
}