diff --git a/lib/utils.js b/lib/utils.js index 37572ae2..56896261 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -165,8 +165,10 @@ const formatParam = typeShorthands => param => { export const formatParams = (params = [], typeShorthands) => `(${params.map(formatParam(typeShorthands)).join(", ")})`; -export const comment = (object, name, text) => - template`COMMENT ON ${object} "${name}" IS ${text ? `'${text}'` : "NULL"};`; +export const comment = (object, name, text) => { + const cmt = escapeValue(text || null); + return template`COMMENT ON ${object} "${name}" IS ${cmt};`; +}; export const formatLines = (lines, replace = " ", separator = ",") => lines diff --git a/test/migrations/069_comments.js b/test/migrations/069_comments.js new file mode 100644 index 00000000..92759f1e --- /dev/null +++ b/test/migrations/069_comments.js @@ -0,0 +1,6 @@ +exports.up = pgm => { + pgm.createTable("test-comment", {}, { comment: "table's comment" }); + pgm.dropTable("test-comment"); +}; + +exports.down = () => null;