entc/gen: move migrate annotation creation to init (#1165)

* fix issue with pointer values in Annotation

* entc/gen: move migrate annotation creation to init

Co-authored-by: Ruben de Vries <ruben@rubensayshi.com>
This commit is contained in:
Ariel Mashraki
2021-01-13 12:00:30 +02:00
committed by GitHub
parent 63f8ad6fa4
commit 76c5e48ef8
6 changed files with 55 additions and 9 deletions

View File

@@ -24,7 +24,6 @@ var (
Columns: UsersColumns,
PrimaryKey: []*schema.Column{UsersColumns[0]},
ForeignKeys: []*schema.ForeignKey{},
Annotation: &entsql.Annotation{Table: "Users", Charset: "utf8mb4"},
}
// Tables holds all the tables in the schema.
Tables = []*schema.Table{
@@ -33,4 +32,10 @@ var (
)
func init() {
UsersTable.Annotation = &entsql.Annotation{
Table: "Users",
Charset: "utf8mb4",
}
UsersTable.Annotation.Incremental = new(bool)
*UsersTable.Annotation.Incremental = false
}

View File

@@ -57,9 +57,11 @@ func (User) Mixin() []ent.Mixin {
// Annotations of the User schema.
func (User) Annotations() []schema.Annotation {
incremental := false
return []schema.Annotation{
entsql.Annotation{
Table: "Users",
Table: "Users",
Incremental: &incremental,
},
}
}