diff --git a/session_schema.go b/session_schema.go index e9ed9ec5..110285c2 100644 --- a/session_schema.go +++ b/session_schema.go @@ -351,9 +351,30 @@ func (session *Session) Sync(beans ...interface{}) error { if err = session.addColumn(col.Name); err != nil { return err } + + // add column comment for postgres + if col.Comment != "" && engine.Dialect().URI().DBType == schemas.POSTGRES { + // @see: integrations/engine_test.go#TestGetColumns + addColumnCommentSql := fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s'", session.engine.Quote(tbNameWithSchema), session.engine.Quote(col.Name), col.Comment) + _, err = session.Exec(addColumnCommentSql) + if err != nil { + return err + } + } + continue } + // add column comment for postgres + if col.Comment != "" && engine.Dialect().URI().DBType == schemas.POSTGRES { + // @see: integrations/engine_test.go#TestGetColumns + addColumnCommentSql := fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s'", session.engine.Quote(tbNameWithSchema), session.engine.Quote(col.Name), col.Comment) + _, err = session.Exec(addColumnCommentSql) + if err != nil { + return err + } + } + err = nil expectedType := engine.dialect.SQLType(col) curType := engine.dialect.SQLType(oriCol)