This repository was archived by the owner on May 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathschema.go
442 lines (438 loc) · 16.1 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
// Code generated by entc, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// ChatUsersColumns holds the columns for the "chat_users" table.
ChatUsersColumns = []*schema.Column{
{Name: "id", Type: field.TypeString},
{Name: "token", Type: field.TypeString},
{Name: "refresh", Type: field.TypeString},
{Name: "expiry", Type: field.TypeTime},
{Name: "bot_token", Type: field.TypeString},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "user_id", Type: field.TypeInt64, Unique: true},
}
// ChatUsersTable holds the schema information for the "chat_users" table.
ChatUsersTable = &schema.Table{
Name: "chat_users",
Columns: ChatUsersColumns,
PrimaryKey: []*schema.Column{ChatUsersColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "chat_users_users_chat_user",
Columns: []*schema.Column{ChatUsersColumns[7]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// DeploymentsColumns holds the columns for the "deployments" table.
DeploymentsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "number", Type: field.TypeInt},
{Name: "type", Type: field.TypeEnum, Enums: []string{"commit", "branch", "tag"}, Default: "commit"},
{Name: "env", Type: field.TypeString},
{Name: "ref", Type: field.TypeString},
{Name: "dynamic_payload", Type: field.TypeJSON, Nullable: true},
{Name: "status", Type: field.TypeEnum, Enums: []string{"waiting", "created", "queued", "running", "success", "failure", "canceled"}, Default: "waiting"},
{Name: "uid", Type: field.TypeInt64, Nullable: true},
{Name: "sha", Type: field.TypeString, Nullable: true},
{Name: "html_url", Type: field.TypeString, Nullable: true, Size: 2000},
{Name: "production_environment", Type: field.TypeBool, Default: false},
{Name: "is_rollback", Type: field.TypeBool, Default: false},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "is_approval_enabled", Type: field.TypeBool, Nullable: true},
{Name: "required_approval_count", Type: field.TypeInt, Nullable: true},
{Name: "repo_id", Type: field.TypeInt64},
{Name: "user_id", Type: field.TypeInt64, Nullable: true},
}
// DeploymentsTable holds the schema information for the "deployments" table.
DeploymentsTable = &schema.Table{
Name: "deployments",
Columns: DeploymentsColumns,
PrimaryKey: []*schema.Column{DeploymentsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "deployments_repos_deployments",
Columns: []*schema.Column{DeploymentsColumns[16]},
RefColumns: []*schema.Column{ReposColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "deployments_users_deployments",
Columns: []*schema.Column{DeploymentsColumns[17]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
Indexes: []*schema.Index{
{
Name: "deployment_repo_id_env_status_updated_at",
Unique: false,
Columns: []*schema.Column{DeploymentsColumns[16], DeploymentsColumns[3], DeploymentsColumns[6], DeploymentsColumns[13]},
},
{
Name: "deployment_repo_id_env_created_at",
Unique: false,
Columns: []*schema.Column{DeploymentsColumns[16], DeploymentsColumns[3], DeploymentsColumns[12]},
},
{
Name: "deployment_repo_id_created_at",
Unique: false,
Columns: []*schema.Column{DeploymentsColumns[16], DeploymentsColumns[12]},
},
{
Name: "deployment_repo_id_number",
Unique: true,
Columns: []*schema.Column{DeploymentsColumns[16], DeploymentsColumns[1]},
},
{
Name: "deployment_uid",
Unique: false,
Columns: []*schema.Column{DeploymentsColumns[7]},
},
{
Name: "deployment_created_at_status",
Unique: false,
Columns: []*schema.Column{DeploymentsColumns[12], DeploymentsColumns[6]},
},
},
}
// DeploymentStatisticsColumns holds the columns for the "deployment_statistics" table.
DeploymentStatisticsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "env", Type: field.TypeString},
{Name: "count", Type: field.TypeInt, Default: 0},
{Name: "rollback_count", Type: field.TypeInt, Default: 0},
{Name: "additions", Type: field.TypeInt, Default: 0},
{Name: "deletions", Type: field.TypeInt, Default: 0},
{Name: "changes", Type: field.TypeInt, Default: 0},
{Name: "lead_time_seconds", Type: field.TypeInt, Default: 0},
{Name: "commit_count", Type: field.TypeInt, Default: 0},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "repo_id", Type: field.TypeInt64},
}
// DeploymentStatisticsTable holds the schema information for the "deployment_statistics" table.
DeploymentStatisticsTable = &schema.Table{
Name: "deployment_statistics",
Columns: DeploymentStatisticsColumns,
PrimaryKey: []*schema.Column{DeploymentStatisticsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "deployment_statistics_repos_deployment_statistics",
Columns: []*schema.Column{DeploymentStatisticsColumns[11]},
RefColumns: []*schema.Column{ReposColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "deploymentstatistics_repo_id_env",
Unique: true,
Columns: []*schema.Column{DeploymentStatisticsColumns[11], DeploymentStatisticsColumns[1]},
},
{
Name: "deploymentstatistics_updated_at",
Unique: false,
Columns: []*schema.Column{DeploymentStatisticsColumns[10]},
},
},
}
// DeploymentStatusColumns holds the columns for the "deployment_status" table.
DeploymentStatusColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "status", Type: field.TypeString},
{Name: "description", Type: field.TypeString, Nullable: true},
{Name: "log_url", Type: field.TypeString, Nullable: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "deployment_id", Type: field.TypeInt},
{Name: "repo_id", Type: field.TypeInt64, Nullable: true},
}
// DeploymentStatusTable holds the schema information for the "deployment_status" table.
DeploymentStatusTable = &schema.Table{
Name: "deployment_status",
Columns: DeploymentStatusColumns,
PrimaryKey: []*schema.Column{DeploymentStatusColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "deployment_status_deployments_deployment_statuses",
Columns: []*schema.Column{DeploymentStatusColumns[6]},
RefColumns: []*schema.Column{DeploymentsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "deployment_status_repos_deployment_statuses",
Columns: []*schema.Column{DeploymentStatusColumns[7]},
RefColumns: []*schema.Column{ReposColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// EventsColumns holds the columns for the "events" table.
EventsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "kind", Type: field.TypeEnum, Enums: []string{"deployment_status", "review"}},
{Name: "type", Type: field.TypeEnum, Enums: []string{"created", "updated", "deleted"}},
{Name: "created_at", Type: field.TypeTime},
{Name: "deleted_id", Type: field.TypeInt, Nullable: true},
{Name: "deployment_status_id", Type: field.TypeInt, Nullable: true},
{Name: "review_id", Type: field.TypeInt, Nullable: true},
}
// EventsTable holds the schema information for the "events" table.
EventsTable = &schema.Table{
Name: "events",
Columns: EventsColumns,
PrimaryKey: []*schema.Column{EventsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "events_deployment_status_event",
Columns: []*schema.Column{EventsColumns[5]},
RefColumns: []*schema.Column{DeploymentStatusColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "events_reviews_event",
Columns: []*schema.Column{EventsColumns[6]},
RefColumns: []*schema.Column{ReviewsColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "event_created_at",
Unique: false,
Columns: []*schema.Column{EventsColumns[3]},
},
},
}
// LocksColumns holds the columns for the "locks" table.
LocksColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "env", Type: field.TypeString},
{Name: "expired_at", Type: field.TypeTime, Nullable: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "repo_id", Type: field.TypeInt64},
{Name: "user_id", Type: field.TypeInt64, Nullable: true},
}
// LocksTable holds the schema information for the "locks" table.
LocksTable = &schema.Table{
Name: "locks",
Columns: LocksColumns,
PrimaryKey: []*schema.Column{LocksColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "locks_repos_locks",
Columns: []*schema.Column{LocksColumns[4]},
RefColumns: []*schema.Column{ReposColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "locks_users_locks",
Columns: []*schema.Column{LocksColumns[5]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
Indexes: []*schema.Index{
{
Name: "lock_repo_id_env",
Unique: true,
Columns: []*schema.Column{LocksColumns[4], LocksColumns[1]},
},
},
}
// NotificationRecordsColumns holds the columns for the "notification_records" table.
NotificationRecordsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "event_id", Type: field.TypeInt, Unique: true, Nullable: true},
}
// NotificationRecordsTable holds the schema information for the "notification_records" table.
NotificationRecordsTable = &schema.Table{
Name: "notification_records",
Columns: NotificationRecordsColumns,
PrimaryKey: []*schema.Column{NotificationRecordsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "notification_records_events_notification_record",
Columns: []*schema.Column{NotificationRecordsColumns[1]},
RefColumns: []*schema.Column{EventsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// PermsColumns holds the columns for the "perms" table.
PermsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "repo_perm", Type: field.TypeEnum, Enums: []string{"read", "write", "admin"}, Default: "read"},
{Name: "synced_at", Type: field.TypeTime, Nullable: true, SchemaType: map[string]string{"mysql": "timestamp(6)"}},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "repo_id", Type: field.TypeInt64},
{Name: "user_id", Type: field.TypeInt64},
}
// PermsTable holds the schema information for the "perms" table.
PermsTable = &schema.Table{
Name: "perms",
Columns: PermsColumns,
PrimaryKey: []*schema.Column{PermsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "perms_repos_perms",
Columns: []*schema.Column{PermsColumns[5]},
RefColumns: []*schema.Column{ReposColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "perms_users_perms",
Columns: []*schema.Column{PermsColumns[6]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.Cascade,
},
},
Indexes: []*schema.Index{
{
Name: "perm_repo_id_user_id",
Unique: false,
Columns: []*schema.Column{PermsColumns[5], PermsColumns[6]},
},
{
Name: "perm_user_id_synced_at",
Unique: false,
Columns: []*schema.Column{PermsColumns[6], PermsColumns[2]},
},
},
}
// ReposColumns holds the columns for the "repos" table.
ReposColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "namespace", Type: field.TypeString},
{Name: "name", Type: field.TypeString},
{Name: "description", Type: field.TypeString},
{Name: "config_path", Type: field.TypeString, Default: "deploy.yml"},
{Name: "active", Type: field.TypeBool, Default: false},
{Name: "webhook_id", Type: field.TypeInt64, Nullable: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "latest_deployed_at", Type: field.TypeTime, Nullable: true},
{Name: "owner_id", Type: field.TypeInt64, Nullable: true},
}
// ReposTable holds the schema information for the "repos" table.
ReposTable = &schema.Table{
Name: "repos",
Columns: ReposColumns,
PrimaryKey: []*schema.Column{ReposColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "repos_users_repos",
Columns: []*schema.Column{ReposColumns[10]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
Indexes: []*schema.Index{
{
Name: "repo_namespace_name",
Unique: true,
Columns: []*schema.Column{ReposColumns[1], ReposColumns[2]},
},
{
Name: "repo_name",
Unique: false,
Columns: []*schema.Column{ReposColumns[2]},
},
{
Name: "repo_active",
Unique: false,
Columns: []*schema.Column{ReposColumns[5]},
},
},
}
// ReviewsColumns holds the columns for the "reviews" table.
ReviewsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "status", Type: field.TypeEnum, Enums: []string{"pending", "rejected", "approved"}, Default: "pending"},
{Name: "comment", Type: field.TypeString, Nullable: true, Size: 2147483647},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "deployment_id", Type: field.TypeInt},
{Name: "user_id", Type: field.TypeInt64, Nullable: true},
}
// ReviewsTable holds the schema information for the "reviews" table.
ReviewsTable = &schema.Table{
Name: "reviews",
Columns: ReviewsColumns,
PrimaryKey: []*schema.Column{ReviewsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "reviews_deployments_reviews",
Columns: []*schema.Column{ReviewsColumns[5]},
RefColumns: []*schema.Column{DeploymentsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "reviews_users_reviews",
Columns: []*schema.Column{ReviewsColumns[6]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// UsersColumns holds the columns for the "users" table.
UsersColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "login", Type: field.TypeString, Unique: true},
{Name: "avatar", Type: field.TypeString},
{Name: "admin", Type: field.TypeBool, Default: false},
{Name: "token", Type: field.TypeString},
{Name: "refresh", Type: field.TypeString},
{Name: "expiry", Type: field.TypeTime},
{Name: "hash", Type: field.TypeString, Unique: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
}
// UsersTable holds the schema information for the "users" table.
UsersTable = &schema.Table{
Name: "users",
Columns: UsersColumns,
PrimaryKey: []*schema.Column{UsersColumns[0]},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
ChatUsersTable,
DeploymentsTable,
DeploymentStatisticsTable,
DeploymentStatusTable,
EventsTable,
LocksTable,
NotificationRecordsTable,
PermsTable,
ReposTable,
ReviewsTable,
UsersTable,
}
)
func init() {
ChatUsersTable.ForeignKeys[0].RefTable = UsersTable
DeploymentsTable.ForeignKeys[0].RefTable = ReposTable
DeploymentsTable.ForeignKeys[1].RefTable = UsersTable
DeploymentStatisticsTable.ForeignKeys[0].RefTable = ReposTable
DeploymentStatusTable.ForeignKeys[0].RefTable = DeploymentsTable
DeploymentStatusTable.ForeignKeys[1].RefTable = ReposTable
EventsTable.ForeignKeys[0].RefTable = DeploymentStatusTable
EventsTable.ForeignKeys[1].RefTable = ReviewsTable
LocksTable.ForeignKeys[0].RefTable = ReposTable
LocksTable.ForeignKeys[1].RefTable = UsersTable
NotificationRecordsTable.ForeignKeys[0].RefTable = EventsTable
PermsTable.ForeignKeys[0].RefTable = ReposTable
PermsTable.ForeignKeys[1].RefTable = UsersTable
ReposTable.ForeignKeys[0].RefTable = UsersTable
ReviewsTable.ForeignKeys[0].RefTable = DeploymentsTable
ReviewsTable.ForeignKeys[1].RefTable = UsersTable
}