'use strict'; /** * 自定义快递编码字典。 * * 由「系统管理 → 自定义快递编码」维护(全局字典,不区分主体): * - code:自定义编码(订单 logistics_code 直接写这个值,推送奇门时原样下发) * - name:自定义名称(订单 logistics_name 直接写这个值) * - express_code:对应的系统快递编码(express_companies.code,便于对账与映射) * * 订单选择自定义快递后,logistics_code / logistics_name 保存自定义值, * 推送 WMS(奇门 deliveryOrder.logisticsCode / logisticsName)时保持自定义值不变。 */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable('custom_express_codes', { id: { type: Sequelize.BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键', }, code: { type: Sequelize.STRING(50), allowNull: false, comment: '自定义快递编码(订单 logistics_code)', }, name: { type: Sequelize.STRING(100), allowNull: false, comment: '自定义快递名称(订单 logistics_name)', }, express_code: { type: Sequelize.STRING(50), allowNull: false, comment: '对应的系统快递编码(express_companies.code)', }, sort: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0, comment: '排序(下拉展示顺序,越小越靠前)', }, status: { type: Sequelize.TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用', }, remark: { type: Sequelize.STRING(255), allowNull: true, comment: '备注', }, created_at: { type: Sequelize.DATE, allowNull: true, comment: '创建时间' }, updated_at: { type: Sequelize.DATE, allowNull: true, comment: '更新时间' }, }); await queryInterface.addIndex('custom_express_codes', [ 'code' ], { name: 'uk_custom_express_codes_code', unique: true, }); await queryInterface.addIndex('custom_express_codes', [ 'express_code' ], { name: 'idx_custom_express_codes_express_code', }); }, async down(queryInterface) { await queryInterface.removeIndex('custom_express_codes', 'idx_custom_express_codes_express_code'); await queryInterface.removeIndex('custom_express_codes', 'uk_custom_express_codes_code'); await queryInterface.dropTable('custom_express_codes'); }, };