'use strict'; module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.createTable('teams', { team_uid: { type: Sequelize.INTEGER, primaryKey: true, // 注意:运行库中 teams 表真实自增主键为 id,team_uid 为非自增普通列, // 由应用层(importFromExcel 显式 MAX+1)赋值。故此处不声明 autoIncrement, // 使迁移与运行库一致,避免新建库时 team_uid 被设为自增而与运行库行为背离。 allowNull: false, comment: '团队唯一标识(由应用层显式生成,非 DB 自增)', }, group_name: { type: Sequelize.STRING(64), allowNull: false, comment: '组别名称', }, team_id: { type: Sequelize.STRING(64), allowNull: false, unique: true, comment: '团队编号(唯一)', }, team_number: { type: Sequelize.STRING(32), allowNull: true, comment: '团队序号', }, address: { type: Sequelize.STRING(255), allowNull: true, comment: '地址', }, created_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, updated_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), comment: '更新时间', }, }).then(() => { return queryInterface.addIndex('teams', ['group_name'], { name: 'idx_group_name' }); }); }, down: async (queryInterface, Sequelize) => { await queryInterface.dropTable('teams'); }, };