Add a field type of float with 0 as the default value make the migration fail.
It's should migrate with no problem
Steps:
field.Float("point").Default(0)go run entgo.io/ent/cmd/ent generate --feature privacy ./ent/schema| Tech | Version |
| ----------- | ------- |
| Go | 1.15.5 |
| Ent | 0.6.0 |
| Database | Postgres |
Hey @HarikiRito,
I tried reproducing this on my local machine and it seems to work fine. Can you share more details on the current behavior? Specifically a stack trace on the error, and if you can share an example schema it will also be helpful.
EDIT: in addition, what postgres version are you using? Also, are you trying to add a new field with a default value, or are you trying to add a default value to an existing column?
@rotemtam I believe the cause of this problem is when schema generate it doesn't have a "Default" field. And I'm using postgres:13.1 docker container
This happened if I add a new field with 0 as the default

migrate/schema.go

Here is the error message when I run the app
alter table "posts": ERROR: column "actual_point" of relation "posts" contains null values (SQLSTATE 23502)
Thanks for reporting this @HarikiRito 馃檹
Most helpful comment
Thanks for reporting this @HarikiRito 馃檹
1287 fixed the issue. Closing