-
Notifications
You must be signed in to change notification settings - Fork 173
/
schema.go
230 lines (226 loc) · 8.67 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// AttachmentsColumns holds the columns for the "attachments" table.
AttachmentsColumns = []*schema.Column{
{Name: "id", Type: field.TypeUUID},
{Name: "pet_attachment", Type: field.TypeInt, Nullable: true},
{Name: "user_attachment", Type: field.TypeUint32, Unique: true, Nullable: true},
}
// AttachmentsTable holds the schema information for the "attachments" table.
AttachmentsTable = &schema.Table{
Name: "attachments",
Columns: AttachmentsColumns,
PrimaryKey: []*schema.Column{AttachmentsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "attachments_pets_attachment",
Columns: []*schema.Column{AttachmentsColumns[1]},
RefColumns: []*schema.Column{PetsColumns[0]},
OnDelete: schema.SetNull,
},
{
Symbol: "attachments_users_attachment",
Columns: []*schema.Column{AttachmentsColumns[2]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// GroupsColumns holds the columns for the "groups" table.
GroupsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString},
}
// GroupsTable holds the schema information for the "groups" table.
GroupsTable = &schema.Table{
Name: "groups",
Columns: GroupsColumns,
PrimaryKey: []*schema.Column{GroupsColumns[0]},
}
// MultiWordSchemasColumns holds the columns for the "multi_word_schemas" table.
MultiWordSchemasColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "unit", Type: field.TypeEnum, Enums: []string{"m", "ft"}, Default: "m"},
}
// MultiWordSchemasTable holds the schema information for the "multi_word_schemas" table.
MultiWordSchemasTable = &schema.Table{
Name: "multi_word_schemas",
Columns: MultiWordSchemasColumns,
PrimaryKey: []*schema.Column{MultiWordSchemasColumns[0]},
}
// NilExamplesColumns holds the columns for the "nil_examples" table.
NilExamplesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "str_nil", Type: field.TypeString, Nullable: true},
{Name: "time_nil", Type: field.TypeTime, Nullable: true},
}
// NilExamplesTable holds the schema information for the "nil_examples" table.
NilExamplesTable = &schema.Table{
Name: "nil_examples",
Columns: NilExamplesColumns,
PrimaryKey: []*schema.Column{NilExamplesColumns[0]},
}
// PetsColumns holds the columns for the "pets" table.
PetsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "user_pet", Type: field.TypeUint32, Unique: true, 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_users_pet",
Columns: []*schema.Column{PetsColumns[1]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// PoniesColumns holds the columns for the "ponies" table.
PoniesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString},
}
// PoniesTable holds the schema information for the "ponies" table.
PoniesTable = &schema.Table{
Name: "ponies",
Columns: PoniesColumns,
PrimaryKey: []*schema.Column{PoniesColumns[0]},
}
// SkipEdgeExamplesColumns holds the columns for the "skip_edge_examples" table.
SkipEdgeExamplesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "user_skip_edge", Type: field.TypeUint32, Unique: true, Nullable: true},
}
// SkipEdgeExamplesTable holds the schema information for the "skip_edge_examples" table.
SkipEdgeExamplesTable = &schema.Table{
Name: "skip_edge_examples",
Columns: SkipEdgeExamplesColumns,
PrimaryKey: []*schema.Column{SkipEdgeExamplesColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "skip_edge_examples_users_skip_edge",
Columns: []*schema.Column{SkipEdgeExamplesColumns[1]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// TodosColumns holds the columns for the "todos" table.
TodosColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "task", Type: field.TypeString},
{Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "in_progress", "done"}, Default: "pending"},
{Name: "todo_user", Type: field.TypeUint32, Nullable: true},
}
// TodosTable holds the schema information for the "todos" table.
TodosTable = &schema.Table{
Name: "todos",
Columns: TodosColumns,
PrimaryKey: []*schema.Column{TodosColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "todos_users_user",
Columns: []*schema.Column{TodosColumns[3]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// UsersColumns holds the columns for the "users" table.
UsersColumns = []*schema.Column{
{Name: "user_id", Type: field.TypeUint32, Increment: true},
{Name: "user_name", Type: field.TypeString, Unique: true},
{Name: "joined", Type: field.TypeTime},
{Name: "points", Type: field.TypeUint},
{Name: "exp", Type: field.TypeUint64},
{Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "active"}},
{Name: "external_id", Type: field.TypeInt, Unique: true},
{Name: "crm_id", Type: field.TypeUUID},
{Name: "banned", Type: field.TypeBool, Default: false},
{Name: "custom_pb", Type: field.TypeUint8},
{Name: "opt_num", Type: field.TypeInt, Nullable: true},
{Name: "opt_str", Type: field.TypeString, Nullable: true},
{Name: "opt_bool", Type: field.TypeBool, Nullable: true},
{Name: "big_int", Type: field.TypeInt, Nullable: true},
{Name: "b_user_1", Type: field.TypeInt, Unique: true, Nullable: true},
{Name: "height_in_cm", Type: field.TypeFloat32, Default: 0},
{Name: "account_balance", Type: field.TypeFloat64, Default: 0},
{Name: "unnecessary", Type: field.TypeString, Nullable: true},
{Name: "type", Type: field.TypeString, Nullable: true},
{Name: "labels", Type: field.TypeJSON, Nullable: true},
{Name: "device_type", Type: field.TypeEnum, Enums: []string{"GLOWY9000", "SPEEDY300"}, Default: "GLOWY9000"},
{Name: "omit_prefix", Type: field.TypeEnum, Enums: []string{"foo", "bar"}},
{Name: "user_group", Type: field.TypeInt, Nullable: true},
}
// UsersTable holds the schema information for the "users" table.
UsersTable = &schema.Table{
Name: "users",
Columns: UsersColumns,
PrimaryKey: []*schema.Column{UsersColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "users_groups_group",
Columns: []*schema.Column{UsersColumns[22]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// AttachmentRecipientsColumns holds the columns for the "attachment_recipients" table.
AttachmentRecipientsColumns = []*schema.Column{
{Name: "attachment_id", Type: field.TypeUUID},
{Name: "user_id", Type: field.TypeUint32},
}
// AttachmentRecipientsTable holds the schema information for the "attachment_recipients" table.
AttachmentRecipientsTable = &schema.Table{
Name: "attachment_recipients",
Columns: AttachmentRecipientsColumns,
PrimaryKey: []*schema.Column{AttachmentRecipientsColumns[0], AttachmentRecipientsColumns[1]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "attachment_recipients_attachment_id",
Columns: []*schema.Column{AttachmentRecipientsColumns[0]},
RefColumns: []*schema.Column{AttachmentsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "attachment_recipients_user_id",
Columns: []*schema.Column{AttachmentRecipientsColumns[1]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
AttachmentsTable,
GroupsTable,
MultiWordSchemasTable,
NilExamplesTable,
PetsTable,
PoniesTable,
SkipEdgeExamplesTable,
TodosTable,
UsersTable,
AttachmentRecipientsTable,
}
)
func init() {
AttachmentsTable.ForeignKeys[0].RefTable = PetsTable
AttachmentsTable.ForeignKeys[1].RefTable = UsersTable
PetsTable.ForeignKeys[0].RefTable = UsersTable
SkipEdgeExamplesTable.ForeignKeys[0].RefTable = UsersTable
TodosTable.ForeignKeys[0].RefTable = UsersTable
UsersTable.ForeignKeys[0].RefTable = GroupsTable
AttachmentRecipientsTable.ForeignKeys[0].RefTable = AttachmentsTable
AttachmentRecipientsTable.ForeignKeys[1].RefTable = UsersTable
}