forked from ogen-go/ent2ogen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.go
114 lines (110 loc) · 4.49 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 (
// SchemaAsColumns holds the columns for the "schema_as" table.
SchemaAsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "int64", Type: field.TypeInt64},
{Name: "string_bindto_foobar", Type: field.TypeString},
{Name: "string_optional_nullable", Type: field.TypeString, Nullable: true},
{Name: "optional_nullable_bool", Type: field.TypeBool, Nullable: true},
{Name: "jsontype_strings", Type: field.TypeJSON},
{Name: "jsontype_strings_optional", Type: field.TypeJSON, Nullable: true},
{Name: "jsontype_ints", Type: field.TypeJSON},
{Name: "jsontype_ints_optional", Type: field.TypeJSON, Nullable: true},
{Name: "required_enum", Type: field.TypeEnum, Enums: []string{"a", "b"}},
{Name: "optional_nullable_enum", Type: field.TypeEnum, Nullable: true, Enums: []string{"c", "d"}},
{Name: "bytes", Type: field.TypeBytes},
{Name: "schemaa_edge_schemab_unique_required", Type: field.TypeInt64},
{Name: "schemaa_edge_schemab_unique_required_bindto_bs", Type: field.TypeInt64},
{Name: "schemaa_edge_schemab_unique_optional", Type: field.TypeInt64, Nullable: true},
}
// SchemaAsTable holds the schema information for the "schema_as" table.
SchemaAsTable = &schema.Table{
Name: "schema_as",
Columns: SchemaAsColumns,
PrimaryKey: []*schema.Column{SchemaAsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "schema_as_schema_bs_edge_schemab_unique_required",
Columns: []*schema.Column{SchemaAsColumns[12]},
RefColumns: []*schema.Column{SchemaBsColumns[0]},
OnDelete: schema.NoAction,
},
{
Symbol: "schema_as_schema_bs_edge_schemab_unique_required_bindto_bs",
Columns: []*schema.Column{SchemaAsColumns[13]},
RefColumns: []*schema.Column{SchemaBsColumns[0]},
OnDelete: schema.NoAction,
},
{
Symbol: "schema_as_schema_bs_edge_schemab_unique_optional",
Columns: []*schema.Column{SchemaAsColumns[14]},
RefColumns: []*schema.Column{SchemaBsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// SchemaBsColumns holds the columns for the "schema_bs" table.
SchemaBsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt64, Increment: true},
{Name: "schemaa_edge_schemab", Type: field.TypeInt, Nullable: true},
}
// SchemaBsTable holds the schema information for the "schema_bs" table.
SchemaBsTable = &schema.Table{
Name: "schema_bs",
Columns: SchemaBsColumns,
PrimaryKey: []*schema.Column{SchemaBsColumns[0]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "schema_bs_schema_as_edge_schemab",
Columns: []*schema.Column{SchemaBsColumns[1]},
RefColumns: []*schema.Column{SchemaAsColumns[0]},
OnDelete: schema.SetNull,
},
},
}
// SchemaaEdgeSchemaaRecursiveColumns holds the columns for the "schemaa_edge_schemaa_recursive" table.
SchemaaEdgeSchemaaRecursiveColumns = []*schema.Column{
{Name: "schemaa_id", Type: field.TypeInt},
{Name: "edge_schemaa_recursive_id", Type: field.TypeInt},
}
// SchemaaEdgeSchemaaRecursiveTable holds the schema information for the "schemaa_edge_schemaa_recursive" table.
SchemaaEdgeSchemaaRecursiveTable = &schema.Table{
Name: "schemaa_edge_schemaa_recursive",
Columns: SchemaaEdgeSchemaaRecursiveColumns,
PrimaryKey: []*schema.Column{SchemaaEdgeSchemaaRecursiveColumns[0], SchemaaEdgeSchemaaRecursiveColumns[1]},
ForeignKeys: []*schema.ForeignKey{
{
Symbol: "schemaa_edge_schemaa_recursive_schemaa_id",
Columns: []*schema.Column{SchemaaEdgeSchemaaRecursiveColumns[0]},
RefColumns: []*schema.Column{SchemaAsColumns[0]},
OnDelete: schema.Cascade,
},
{
Symbol: "schemaa_edge_schemaa_recursive_edge_schemaa_recursive_id",
Columns: []*schema.Column{SchemaaEdgeSchemaaRecursiveColumns[1]},
RefColumns: []*schema.Column{SchemaAsColumns[0]},
OnDelete: schema.Cascade,
},
},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
SchemaAsTable,
SchemaBsTable,
SchemaaEdgeSchemaaRecursiveTable,
}
)
func init() {
SchemaAsTable.ForeignKeys[0].RefTable = SchemaBsTable
SchemaAsTable.ForeignKeys[1].RefTable = SchemaBsTable
SchemaAsTable.ForeignKeys[2].RefTable = SchemaBsTable
SchemaBsTable.ForeignKeys[0].RefTable = SchemaAsTable
SchemaaEdgeSchemaaRecursiveTable.ForeignKeys[0].RefTable = SchemaAsTable
SchemaaEdgeSchemaaRecursiveTable.ForeignKeys[1].RefTable = SchemaAsTable
}