mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
dialect/entsql: add support for column default using annotation
Fixed #1033
This commit is contained in:
committed by
Ariel Mashraki
parent
3db3f5fd1a
commit
745afde770
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user