运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。 已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
68 lines
1.8 KiB
JavaScript
68 lines
1.8 KiB
JavaScript
'use strict';
|
||
|
||
module.exports = {
|
||
up: async (queryInterface, Sequelize) => {
|
||
await queryInterface.createTable('choice_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: '题目内容',
|
||
},
|
||
options: {
|
||
type: Sequelize.JSON,
|
||
allowNull: false,
|
||
comment: '选项列表 [{ key: "A", text: "..." }, ...]',
|
||
},
|
||
answer: {
|
||
type: Sequelize.STRING(10),
|
||
allowNull: false,
|
||
comment: '正确答案(如 A / AB / ABCD)',
|
||
},
|
||
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('choice_questions', ['group'], { name: 'idx_choice_group' }),
|
||
queryInterface.addIndex('choice_questions', ['sort_order'], { name: 'idx_choice_sort' }),
|
||
]);
|
||
});
|
||
},
|
||
|
||
down: async (queryInterface) => {
|
||
await queryInterface.dropTable('choice_questions');
|
||
},
|
||
}; |