add column comment for postgres
This commit is contained in:
parent
5feff03a17
commit
6fb5873890
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue