95 lines
2.9 KiB
JavaScript
95 lines
2.9 KiB
JavaScript
|
|
'use strict';
|
|||
|
|
|
|||
|
|
module.exports = {
|
|||
|
|
up: async (queryInterface, Sequelize) => {
|
|||
|
|
await queryInterface.createTable('aggregation', {
|
|||
|
|
aggregation_uid: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
primaryKey: true,
|
|||
|
|
autoIncrement: true,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '报名记录唯一标识',
|
|||
|
|
},
|
|||
|
|
competition_uid: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '赛事ID(关联competition_info)',
|
|||
|
|
references: { model: 'competition_info', key: 'competition_uid' },
|
|||
|
|
onUpdate: 'CASCADE',
|
|||
|
|
onDelete: 'CASCADE',
|
|||
|
|
},
|
|||
|
|
team_uid: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '团队ID(关联teams)',
|
|||
|
|
references: { model: 'teams', key: 'team_uid' },
|
|||
|
|
onUpdate: 'CASCADE',
|
|||
|
|
onDelete: 'CASCADE',
|
|||
|
|
},
|
|||
|
|
account_uid: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '用户ID(关联accounts)',
|
|||
|
|
references: { model: 'accounts', key: 'uid' },
|
|||
|
|
onUpdate: 'CASCADE',
|
|||
|
|
onDelete: 'CASCADE',
|
|||
|
|
},
|
|||
|
|
identity: {
|
|||
|
|
type: Sequelize.STRING(32),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '身份标识',
|
|||
|
|
},
|
|||
|
|
is_registrant: {
|
|||
|
|
type: Sequelize.TINYINT,
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 0,
|
|||
|
|
comment: '是否为主要报名人:0否 1是',
|
|||
|
|
},
|
|||
|
|
registration_form: {
|
|||
|
|
type: Sequelize.STRING(512),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '报名表文件路径',
|
|||
|
|
},
|
|||
|
|
stamped_form: {
|
|||
|
|
type: Sequelize.STRING(512),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '盖章报名表文件路径',
|
|||
|
|
},
|
|||
|
|
audit_status: {
|
|||
|
|
type: Sequelize.STRING(32),
|
|||
|
|
allowNull: false,
|
|||
|
|
defaultValue: 'pending',
|
|||
|
|
comment: '审核状态:pending/approved/rejected',
|
|||
|
|
},
|
|||
|
|
reject_reason: {
|
|||
|
|
type: Sequelize.STRING(512),
|
|||
|
|
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 Promise.all([
|
|||
|
|
queryInterface.addIndex('aggregation', ['competition_uid'], { name: 'idx_competition_uid' }),
|
|||
|
|
queryInterface.addIndex('aggregation', ['team_uid'], { name: 'idx_team_uid' }),
|
|||
|
|
queryInterface.addIndex('aggregation', ['account_uid'], { name: 'idx_account_uid' }),
|
|||
|
|
queryInterface.addIndex('aggregation', ['audit_status'], { name: 'idx_audit_status' }),
|
|||
|
|
]);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
down: async (queryInterface, Sequelize) => {
|
|||
|
|
await queryInterface.dropTable('aggregation');
|
|||
|
|
},
|
|||
|
|
};
|