-
Notifications
You must be signed in to change notification settings - Fork 890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix comments lost in generated DDL. #3052
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this, @chaosue. It's appreciated! 🙏
I think this change should be added to EntSQL annotation, because I prefer not to trigger migration changes to all users that use the Comment
option today. Also, some users, like myself, care only about the code comments and do not need database comments.
Hey @chaosue! Any update on this PR? |
After a discussion with Cheng on Discord, we think the configuration can be simplified by providing a single annotation in the func (T) Annotations() []schema.Annotation {
return []schema.Annotation{
// WithComments indicates that all entity comments
// should be stored in the database schema as well.
entsql.WithComments(true),
}
} Table comments can be implemented once #3164 is merged, and an |
table comment ? entsql.WithComments(true), schema.Comment(string) SQL DDL not work。Will this feature be supported? @a8m |
if you want to generate table comment and column comment, you can upgrade your entgo to master version. And then use like this: type T struct {
ent.Schema
}
func (T) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "t"},
entsql.WithComments(true),
schema.Comment("t is like business unit table"),
}
}
func (T) Fields() []ent.Field {
return []ent.Field{
field.String("name").Comment("unique name"),
field.String("description").Default("").Comment("xxx"),
}
} |
no comments generated on DDL in database, this problem should be fixed, or there's no way to get descriptions for the tables and their columns unless checking the schema golang code, which may lead to impossibility of reverse engineerings and incomprehension for DBA.