const Sequelize = require('sequelize'); /** * 版本信息表模型 * 存储应用版本信息,支持多平台多架构 */ module.exports = (db) => { const version_info = db.define("version_info", { // 版本基本信息 version: { comment: '版本号(x.y.z 格式)', type: Sequelize.STRING(20), allowNull: false }, platform: { comment: '平台类型(win32/darwin/linux)', type: Sequelize.STRING(20), allowNull: false }, arch: { comment: '架构类型(x64/ia32/arm64)', type: Sequelize.STRING(20), allowNull: false }, // 文件信息 download_url: { comment: '下载地址', type: Sequelize.STRING(500), allowNull: false }, file_path: { comment: '服务器文件路径', type: Sequelize.STRING(500), allowNull: false }, file_size: { comment: '文件大小(字节)', type: Sequelize.BIGINT, allowNull: true, defaultValue: 0 }, file_hash: { comment: 'SHA256 哈希值', type: Sequelize.STRING(64), allowNull: true }, // 更新信息 release_notes: { comment: '更新日志', type: Sequelize.TEXT, allowNull: true }, force_update: { comment: '是否强制更新(1:是 0:否)', type: Sequelize.TINYINT(1), allowNull: false, defaultValue: 0 }, // 状态信息 status: { comment: '状态(1:启用 0:禁用)', type: Sequelize.TINYINT(1), allowNull: false, defaultValue: 1 }, }, { timestamps: false, indexes: [ { unique: true, fields: ['version', 'platform', 'arch'] }, { unique: false, fields: ['platform', 'arch', 'status'] } ] }); return version_info; };