如何使用knex alertableBuilder更新列注释

How to use knex alertableBuilder to update column comment

迁移文件如下:

import * as Knex from 'knex';
exports.up = async (knex: Knex): Promise<any> => {
  await knex.schema.raw(`
  COMMENT on "USER".user_invite_state is '0 - not sent invitation email, 1 - sent without acknowledged, 2 - sent with acknowledged, 3 - invite failed';
  `);
};
exports.down = async (knex: Knex): Promise<any> => {};

当我进行knex迁移时,出现如下错误: 迁移失败并出现错误: "USER".user_invite_state 上的评论是“0 - 未发送邀请电子邮件,1 - 已发送但未确认,2 - 已发送已确认,3 - 邀请失败”; - "COMMENT on " 处或附近的语法错误 错误:"COMMENT on "

处或附近的语法错误

有人对此有什么想法吗?

您应该使用 queryBuilder,它的全部目的是在不同的数据库语法之间架起桥梁。

export async function up(knex: Knex) {
  await knex.schema.alterTable(tn, t => {
    t.integer('colName')
      .comment('this is my comment')
      .alter();
  });
}