Files
competition-website/database/migrations/016-create-judge-questions.js

63 lines
1.7 KiB
JavaScript
Raw Normal View History

'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('judge_questions', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '题目ID',
},
group: {
type: Sequelize.STRING(20),
allowNull: false,
comment: '组别:zhongzhi/gaozhi',
},
question: {
type: Sequelize.TEXT,
allowNull: false,
comment: '题目内容',
},
answer: {
type: Sequelize.STRING(10),
allowNull: false,
comment: '正确答案:true 或 false',
},
score: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 5,
comment: '分值',
},
sort_order: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
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('judge_questions', ['group'], { name: 'idx_judge_group' }),
queryInterface.addIndex('judge_questions', ['sort_order'], { name: 'idx_judge_sort' }),
]);
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('judge_questions');
},
};