50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 文档表 JSON 列改为 LONGTEXT(2026-09-23):
|
||
* MySQL JSON 列会归一化对象键序(如 value/name → name/value),导致导出 system.json
|
||
* 与原件产生大量无意义 diff。改为 LONGTEXT 存原始 JSON 文本,导出时原样解析,保证无损往返。
|
||
*/
|
||
|
||
const DOC_TABLE = 'wms_api_method_doc';
|
||
const META_TABLE = 'wms_method_doc_meta';
|
||
|
||
module.exports = {
|
||
async up(queryInterface, Sequelize) {
|
||
const columns = [
|
||
[ 'headers', '请求头(JSON 数组文本)' ],
|
||
[ 'params', '入参(JSON 数组文本)' ],
|
||
[ 'response', '响应字段(JSON 数组文本)' ],
|
||
[ 'errors', '错误码(JSON 数组文本)' ],
|
||
];
|
||
for (const [ name, comment ] of columns) {
|
||
await queryInterface.changeColumn(DOC_TABLE, name, {
|
||
type: Sequelize.TEXT('long'),
|
||
allowNull: true,
|
||
comment,
|
||
});
|
||
}
|
||
await queryInterface.changeColumn(META_TABLE, 'headers', {
|
||
type: Sequelize.TEXT('long'),
|
||
allowNull: true,
|
||
comment: '文档全局请求头(JSON 数组文本)',
|
||
});
|
||
},
|
||
|
||
async down(queryInterface, Sequelize) {
|
||
const columns = [ 'headers', 'params', 'response', 'errors' ];
|
||
for (const name of columns) {
|
||
await queryInterface.changeColumn(DOC_TABLE, name, {
|
||
type: Sequelize.JSON,
|
||
allowNull: true,
|
||
comment: name,
|
||
});
|
||
}
|
||
await queryInterface.changeColumn(META_TABLE, 'headers', {
|
||
type: Sequelize.JSON,
|
||
allowNull: true,
|
||
comment: '文档全局请求头(JSON 数组)',
|
||
});
|
||
},
|
||
};
|