Files
competition-website/database/migrations/002-create-teams.js
WorkBuddy a303cf2d53 chore: 后端首次基线提交
运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。
已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
2026-08-17 12:25:42 +08:00

57 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'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');
},
};