From e100edad4be04270b7f048c377ba5a495f491736 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bonicoli Date: Wed, 13 Apr 2022 03:47:26 +0200 Subject: [PATCH] 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. --- dialects/postgres.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dialects/postgres.go b/dialects/postgres.go index a5b080aa..83e4187f 100644 --- a/dialects/postgres.go +++ b/dialects/postgres.go @@ -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 }