Files
competition-website/database/migrations/017-create-word-questions.js

68 lines
1.8 KiB
JavaScript
Raw Normal View History

'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('word_questions', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '题目ID',
},
group: {
type: Sequelize.STRING(20),
allowNull: false,
comment: '组别:zhongzhi/gaozhi',
},
title: {
type: Sequelize.STRING(200),
allowNull: false,
comment: '题目标题',
},
description: {
type: Sequelize.TEXT,
allowNull: true,
comment: '题目描述/操作要求',
},
score: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 30,
comment: '分值',
},
sort_order: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '排序',
},
template_path: {
type: Sequelize.STRING(500),
allowNull: true,
comment: 'Word 模板文件路径',
},
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('word_questions', ['group'], { name: 'idx_word_group' }),
queryInterface.addIndex('word_questions', ['sort_order'], { name: 'idx_word_sort' }),
]);
});
},
down: async (queryInterface) => {
await queryInterface.dropTable('word_questions');
},
};