PostgreSQL: enable comment on column

The oldest unsupported version documentation
(https://www.postgresql.org/docs/7.1/sql-comment.html) states that
comment on a column is supported.
This commit is contained in:
Pierre-Louis Bonicoli 2022-04-13 03:47:26 +02:00
parent bde3ea6ff7
commit e100edad4b
No known key found for this signature in database
GPG Key ID: 06914C4A5EDAA6DD
1 changed files with 8 additions and 0 deletions

View File

@ -1354,6 +1354,14 @@ func (db *postgres) CreateTableSQL(ctx context.Context, queryer core.Queryer, ta
commentSQL += fmt.Sprintf("COMMENT ON TABLE %s IS '%s'", quoter.Quote(tableName), table.Comment)
}
for _, colName := range table.ColumnsSeq() {
col := table.GetColumn(colName)
if len(col.Comment) > 0 {
commentSQL += fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s'", quoter.Quote(tableName), quoter.Quote(col.Name), col.Comment)
}
}
return createTableSQL + commentSQL, true, nil
}