'use strict'; /** * 参赛团队模型 - Team * * 存储参赛团队的基本信息,包括组别和团队编号等。 * 表名:teams */ module.exports = app => { const { STRING, INTEGER, DATE } = app.Sequelize; const Team = app.model.define('team', { // 主键(业务唯一标识),由应用层显式赋值,不依赖数据库自增。 // 说明:运行库中 teams 表真实自增主键为 id,team_uid 仅是普通 INT 列(非自增)。 // 此处声明 autoIncrement:false,使模型与运行库一致——create 时必须显式传入 team_uid, // 避免 Sequelize 误以为 DB 会生成 team_uid 而省去该列(旧 bug:写入 NULL 导致 G1 团队锁失效)。 team_uid: { type: INTEGER, primaryKey: true, comment: '团队唯一标识(由应用层显式生成,非 DB 自增)', }, // 组别名称:zhongzhi/gaozhi/benke/jiaoshi group_name: { type: STRING(20), allowNull: false, comment: '参赛组别', }, // 团队 ID(外部编号) team_id: { type: STRING(50), allowNull: false, comment: '团队编号', }, // 团队序号(人类可读队伍编号,如 BRICS2026-ST-027-91001,含字母与连字符,必须为字符串) team_number: { type: STRING(50), allowNull: true, defaultValue: null, comment: '团队序号(人类可读队伍编号,如 BRICS2026-ST-027-91001)', }, // 团队地址/地区 address: { type: STRING(200), allowNull: true, defaultValue: null, comment: '团队地址', }, // 记录创建时间 created_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, // 记录更新时间 updated_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '更新时间', }, }, { tableName: 'teams', timestamps: false, underscored: true, indexes: [ { fields: ['group_name'], }, { fields: ['team_id'], }, ], }); return Team; };