ent/entc: corrently reference default value on migrate generation

Summary:
Migration incorrectly generated field default value on storage key inclusion.

Example Field:
```
field.String("tenant").
  StorageKey("organization").
  Default("fb-test"),
```
Generated default of:
```
// DefaultTenant holds the default value on creation for the tenant field.
DefaultTenant = descTenant.Default.(string)
```
But migration references non existent default (storage key is used):
```
{Name: "organization", Type: field.TypeString, Default: user.DefaultOrganization},
```

Reviewed By: a8m

Differential Revision: D17578898

fbshipit-source-id: afca92ac3f34c16100c868a10d0a480139bf4262
This commit is contained in:
Alex Snast
2019-09-25 13:49:50 -07:00
committed by Facebook Github Bot
parent 6cf5b918c3
commit dacc568413
29 changed files with 129 additions and 46 deletions

View File

@@ -449,11 +449,6 @@ func (c *Column) ScanDefault(value string) (err error) {
return nil
}
// HasDefault reports if the column has a default value.
func (c *Column) HasDefault() bool {
return c.Default != nil
}
// defaultValue adds tge `DEFAULT` attribute the the column.
// Note that, in SQLite if a NOT NULL constraint is specified,
// then the column must have a default value which not NULL.