forked from masseelch/elk
/
schema.go
179 lines (175 loc) · 6.53 KB
/
schema.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// Code generated by entc, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// BadgesColumns holds the columns for the "badges" table.
BadgesColumns = []*schema.Column{
{Name: "id", Type: field.TypeUint32, Increment: true},
{Name: "color", Type: field.TypeEnum, Enums: []string{"red", "orange", "yellow", "green", "blue", "indigo", "violet", "purple", "pink", "silver", "gold", "beige", "brown", "grey", "black", "white"}},
{Name: "material", Type: field.TypeEnum, Enums: []string{"leather", "plastic", "fabric"}},
{Name: "pet_badge", Type: field.TypeInt, Unique: true, Nullable: true},
}
// BadgesTable holds the schema information for the "badges" table.
BadgesTable = &schema.Table{
Name: "badges",
Columns: BadgesColumns,
PrimaryKey: []*schema.Column{BadgesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "badges_pets_badge",
Columns: []*schema.Column{BadgesColumns[3]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// PetsColumns holds the columns for the "pets" table.
PetsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "height", Type: field.TypeInt},
{Name: "weight", Type: field.TypeFloat64, Nullable: true},
{Name: "castrated", Type: field.TypeBool},
{Name: "name", Type: field.TypeString, Unique: true},
{Name: "birthday", Type: field.TypeTime, Nullable: true},
{Name: "nicknames", Type: field.TypeJSON, Nullable: true},
{Name: "sex", Type: field.TypeEnum, Enums: []string{"male", "female"}},
{Name: "chip", Type: field.TypeUUID},
{Name: "pet_mentor", Type: field.TypeInt, Unique: true, Nullable: true},
{Name: "pet_spouse", Type: field.TypeInt, Unique: true, Nullable: true},
{Name: "pet_children", Type: field.TypeInt, Nullable: true},
}
// PetsTable holds the schema information for the "pets" table.
PetsTable = &schema.Table{
Name: "pets",
Columns: PetsColumns,
PrimaryKey: []*schema.Column{PetsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "pets_pets_mentor",
Columns: []*schema.Column{PetsColumns[9]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "pets_pets_spouse",
Columns: []*schema.Column{PetsColumns[10]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "pets_pets_children",
Columns: []*schema.Column{PetsColumns[11]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// PlayGroupsColumns holds the columns for the "play_groups" table.
PlayGroupsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "title", Type: field.TypeString},
{Name: "description", Type: field.TypeString, Nullable: true, Size: 2147483647},
{Name: "weekday", Type: field.TypeEnum, Enums: []string{"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}},
}
// PlayGroupsTable holds the schema information for the "play_groups" table.
PlayGroupsTable = &schema.Table{
Name: "play_groups",
Columns: PlayGroupsColumns,
PrimaryKey: []*schema.Column{PlayGroupsColumns[0]},
}
// ToysColumns holds the columns for the "toys" table.
ToysColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "color", Type: field.TypeEnum, Enums: []string{"red", "orange", "yellow", "green", "blue", "indigo", "violet", "purple", "pink", "silver", "gold", "beige", "brown", "grey", "black", "white"}},
{Name: "material", Type: field.TypeEnum, Enums: []string{"leather", "plastic", "fabric"}},
{Name: "title", Type: field.TypeString},
{Name: "pet_toys", Type: field.TypeInt, Nullable: true},
}
// ToysTable holds the schema information for the "toys" table.
ToysTable = &schema.Table{
Name: "toys",
Columns: ToysColumns,
PrimaryKey: []*schema.Column{ToysColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "toys_pets_toys",
Columns: []*schema.Column{ToysColumns[4]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// PetPlayGroupsColumns holds the columns for the "pet_play_groups" table.
PetPlayGroupsColumns = []*schema.Column{
{Name: "pet_id", Type: field.TypeInt},
{Name: "play_group_id", Type: field.TypeInt},
}
// PetPlayGroupsTable holds the schema information for the "pet_play_groups" table.
PetPlayGroupsTable = &schema.Table{
Name: "pet_play_groups",
Columns: PetPlayGroupsColumns,
PrimaryKey: []*schema.Column{PetPlayGroupsColumns[0], PetPlayGroupsColumns[1]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "pet_play_groups_pet_id",
Columns: []*schema.Column{PetPlayGroupsColumns[0]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "pet_play_groups_play_group_id",
Columns: []*schema.Column{PetPlayGroupsColumns[1]},
RefColumns: []*schema.Column{PlayGroupsColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// PetFriendsColumns holds the columns for the "pet_friends" table.
PetFriendsColumns = []*schema.Column{
{Name: "pet_id", Type: field.TypeInt},
{Name: "friend_id", Type: field.TypeInt},
}
// PetFriendsTable holds the schema information for the "pet_friends" table.
PetFriendsTable = &schema.Table{
Name: "pet_friends",
Columns: PetFriendsColumns,
PrimaryKey: []*schema.Column{PetFriendsColumns[0], PetFriendsColumns[1]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "pet_friends_pet_id",
Columns: []*schema.Column{PetFriendsColumns[0]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "pet_friends_friend_id",
Columns: []*schema.Column{PetFriendsColumns[1]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
BadgesTable,
PetsTable,
PlayGroupsTable,
ToysTable,
PetPlayGroupsTable,
PetFriendsTable,
}
)
func init() {
BadgesTable.ForeignKeys[0].RefTable = PetsTable
PetsTable.ForeignKeys[0].RefTable = PetsTable
PetsTable.ForeignKeys[1].RefTable = PetsTable
PetsTable.ForeignKeys[2].RefTable = PetsTable
ToysTable.ForeignKeys[0].RefTable = PetsTable
PetPlayGroupsTable.ForeignKeys[0].RefTable = PetsTable
PetPlayGroupsTable.ForeignKeys[1].RefTable = PlayGroupsTable
PetFriendsTable.ForeignKeys[0].RefTable = PetsTable
PetFriendsTable.ForeignKeys[1].RefTable = PetsTable
}