83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
|
|
'use strict';
|
|||
|
|
|
|||
|
|
module.exports = {
|
|||
|
|
up: async (queryInterface, Sequelize) => {
|
|||
|
|
await queryInterface.createTable('gaozhi_submissions', {
|
|||
|
|
id: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
primaryKey: true,
|
|||
|
|
autoIncrement: true,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '提交记录ID',
|
|||
|
|
},
|
|||
|
|
aggregation_uid: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '报名记录ID(关联aggregation)',
|
|||
|
|
references: { model: 'aggregation', key: 'aggregation_uid' },
|
|||
|
|
onUpdate: 'CASCADE',
|
|||
|
|
onDelete: 'CASCADE',
|
|||
|
|
},
|
|||
|
|
question_uid: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: false,
|
|||
|
|
comment: '题目ID(关联gaozhi_questions)',
|
|||
|
|
references: { model: 'gaozhi_questions', key: 'question_uid' },
|
|||
|
|
onUpdate: 'CASCADE',
|
|||
|
|
onDelete: 'CASCADE',
|
|||
|
|
},
|
|||
|
|
answer_data: {
|
|||
|
|
type: Sequelize.STRING(255),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '提交的答案',
|
|||
|
|
},
|
|||
|
|
is_correct: {
|
|||
|
|
type: Sequelize.TINYINT,
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '是否正确:0错误 1正确',
|
|||
|
|
},
|
|||
|
|
score: {
|
|||
|
|
type: Sequelize.INTEGER,
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: '得分',
|
|||
|
|
},
|
|||
|
|
word_file_path: {
|
|||
|
|
type: Sequelize.STRING(512),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: 'Word文件路径',
|
|||
|
|
},
|
|||
|
|
word_file_name: {
|
|||
|
|
type: Sequelize.STRING(255),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: 'Word文件原始名称',
|
|||
|
|
},
|
|||
|
|
word_file_md5: {
|
|||
|
|
type: Sequelize.STRING(64),
|
|||
|
|
allowNull: true,
|
|||
|
|
comment: 'Word文件MD5哈希值',
|
|||
|
|
},
|
|||
|
|
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('gaozhi_submissions', ['aggregation_uid'], { name: 'idx_aggregation_uid' }),
|
|||
|
|
queryInterface.addIndex('gaozhi_submissions', ['question_uid'], { name: 'idx_question_uid' }),
|
|||
|
|
]);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
down: async (queryInterface, Sequelize) => {
|
|||
|
|
await queryInterface.dropTable('gaozhi_submissions');
|
|||
|
|
},
|
|||
|
|
};
|