/
schema.go
114 lines (110 loc) · 3.93 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
// Code generated by ent, DO NOT EDIT.
package migrate
import (
"entgo.io/ent/dialect/sql/schema"
"entgo.io/ent/schema/field"
)
var (
// DataSourcesColumns holds the columns for the "data_sources" table.
DataSourcesColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString},
{Name: "type", Type: field.TypeString, Default: "unknown"},
{Name: "status", Type: field.TypeString, Default: "idle"},
{Name: "config", Type: field.TypeString, Nullable: true},
{Name: "last_indexed", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"},
{Name: "date_added", Type: field.TypeTime, Default: "CURRENT_TIMESTAMP"},
}
// DataSourcesTable holds the schema information for the "data_sources" table.
DataSourcesTable = &schema.Table{
Name: "data_sources",
Columns: DataSourcesColumns,
PrimaryKey: []*schema.Column{DataSourcesColumns[0]},
}
// GroupsColumns holds the columns for the "groups" table.
GroupsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString, Unique: true},
{Name: "created_at", Type: field.TypeTime},
}
// GroupsTable holds the schema information for the "groups" table.
GroupsTable = &schema.Table{
Name: "groups",
Columns: GroupsColumns,
PrimaryKey: []*schema.Column{GroupsColumns[0]},
}
// PasswordTokensColumns holds the columns for the "password_tokens" table.
PasswordTokensColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "hash", Type: field.TypeString},
{Name: "created_at", Type: field.TypeTime},
{Name: "password_token_user", Type: field.TypeInt},
}
// PasswordTokensTable holds the schema information for the "password_tokens" table.
PasswordTokensTable = &schema.Table{
Name: "password_tokens",
Columns: PasswordTokensColumns,
PrimaryKey: []*schema.Column{PasswordTokensColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "password_tokens_users_user",
Columns: []*schema.Column{PasswordTokensColumns[3]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.NoAction,
},
},
}
// UsersColumns holds the columns for the "users" table.
UsersColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "name", Type: field.TypeString},
{Name: "email", Type: field.TypeString, Unique: true},
{Name: "password", Type: field.TypeString},
{Name: "verified", Type: field.TypeBool, Default: false},
{Name: "created_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]},
}
// GroupUsersColumns holds the columns for the "group_users" table.
GroupUsersColumns = []*schema.Column{
{Name: "group_id", Type: field.TypeInt},
{Name: "user_id", Type: field.TypeInt},
}
// GroupUsersTable holds the schema information for the "group_users" table.
GroupUsersTable = &schema.Table{
Name: "group_users",
Columns: GroupUsersColumns,
PrimaryKey: []*schema.Column{GroupUsersColumns[0], GroupUsersColumns[1]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "group_users_group_id",
Columns: []*schema.Column{GroupUsersColumns[0]},
RefColumns: []*schema.Column{GroupsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "group_users_user_id",
Columns: []*schema.Column{GroupUsersColumns[1]},
RefColumns: []*schema.Column{UsersColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
DataSourcesTable,
GroupsTable,
PasswordTokensTable,
UsersTable,
GroupUsersTable,
}
)
func init() {
PasswordTokensTable.ForeignKeys[0].RefTable = UsersTable
GroupUsersTable.ForeignKeys[0].RefTable = GroupsTable
GroupUsersTable.ForeignKeys[1].RefTable = UsersTable
}