chore: 后端首次基线提交
运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。 已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
This commit is contained in:
69
database/migrations/008-create-gaozhi-questions.js
Normal file
69
database/migrations/008-create-gaozhi-questions.js
Normal file
@@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.createTable('gaozhi_questions', {
|
||||
question_uid: {
|
||||
type: Sequelize.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
allowNull: false,
|
||||
comment: '题目唯一标识',
|
||||
},
|
||||
question: {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: false,
|
||||
comment: '题目内容',
|
||||
},
|
||||
answer: {
|
||||
type: Sequelize.STRING(32),
|
||||
allowNull: false,
|
||||
comment: '正确答案',
|
||||
},
|
||||
question_type: {
|
||||
type: Sequelize.STRING(16),
|
||||
allowNull: false,
|
||||
defaultValue: 'choice',
|
||||
comment: '题目类型:choice选择题 judge判断题',
|
||||
},
|
||||
options: {
|
||||
type: Sequelize.JSON,
|
||||
allowNull: true,
|
||||
comment: '选项(JSON格式)',
|
||||
},
|
||||
score: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
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('gaozhi_questions', ['question_type'], { name: 'idx_question_type' }),
|
||||
queryInterface.addIndex('gaozhi_questions', ['sort_order'], { name: 'idx_sort_order' }),
|
||||
]);
|
||||
});
|
||||
},
|
||||
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.dropTable('gaozhi_questions');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user