dialect/entsql: add support for column default using annotation

Fixed #1033
This commit is contained in:
Ariel Mashraki
2021-04-02 17:10:00 +03:00
committed by Ariel Mashraki
parent 3db3f5fd1a
commit 745afde770
16 changed files with 319 additions and 30 deletions

View File

@@ -7,6 +7,8 @@
package entv2
import (
"time"
"entgo.io/ent/entc/integration/migrate/entv2/schema"
"entgo.io/ent/entc/integration/migrate/entv2/user"
)
@@ -40,4 +42,8 @@ func init() {
userDescTitle := userFields[6].Descriptor()
// user.DefaultTitle holds the default value on creation for the title field.
user.DefaultTitle = userDescTitle.Default.(string)
// userDescCreatedAt is the schema descriptor for created_at field.
userDescCreatedAt := userFields[12].Descriptor()
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
}