'use strict'; /** 7. 主体外部接口表:主体对接外部系统(WMS/ERP/平台等)的接口凭据配置 */ module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable( 'principal_external_apis', { id: { type: Sequelize.BIGINT.UNSIGNED, allowNull: false, autoIncrement: true, primaryKey: true, }, principal_id: { type: Sequelize.BIGINT.UNSIGNED, allowNull: false, comment: '所属主体ID', references: { model: 'principals', key: 'id' }, }, code: { type: Sequelize.STRING(50), allowNull: false, comment: '外部系统标识,如 wms / erp' }, name: { type: Sequelize.STRING(100), allowNull: false, comment: '接口名称' }, base_url: { type: Sequelize.STRING(255), allowNull: true, comment: '接口基础地址' }, app_key: { type: Sequelize.STRING(100), allowNull: true, comment: '应用Key' }, app_secret: { type: Sequelize.STRING(255), allowNull: true, comment: '应用密钥(建议加密存储)' }, extra: { type: Sequelize.JSON, allowNull: true, comment: '扩展配置' }, status: { type: Sequelize.TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' }, created_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), }, updated_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), }, }, { charset: 'utf8mb4', collate: 'utf8mb4_unicode_ci', comment: '主体外部接口表' } ); await queryInterface.addIndex('principal_external_apis', { fields: [ 'principal_id', 'code' ], unique: true, name: 'uk_principal_external_apis', }); }, async down(queryInterface) { await queryInterface.dropTable('principal_external_apis'); }, };