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*、构建/缓存产物。
This commit is contained in:
56
database/migrations/002-create-teams.js
Normal file
56
database/migrations/002-create-teams.js
Normal file
@@ -0,0 +1,56 @@
|
||||
'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');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user