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/004-create-exam-questions.js
Normal file
69
database/migrations/004-create-exam-questions.js
Normal file
@@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 迁移文件:创建试卷题目表(exam_questions)
|
||||
* 存储各组别的试卷题目
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
const { INTEGER, STRING, TEXT, DATE } = Sequelize;
|
||||
|
||||
await queryInterface.createTable('exam_questions', {
|
||||
id: {
|
||||
type: INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
allowNull: false,
|
||||
comment: '题目唯一标识',
|
||||
},
|
||||
group: {
|
||||
type: STRING(20),
|
||||
allowNull: false,
|
||||
comment: '题目所属组别',
|
||||
},
|
||||
title: {
|
||||
type: STRING(200),
|
||||
allowNull: false,
|
||||
comment: '题目标题',
|
||||
},
|
||||
content: {
|
||||
type: TEXT,
|
||||
allowNull: false,
|
||||
comment: '题目内容描述',
|
||||
},
|
||||
score: {
|
||||
type: INTEGER,
|
||||
allowNull: false,
|
||||
comment: '题目分值',
|
||||
},
|
||||
sort_order: {
|
||||
type: INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 0,
|
||||
comment: '排序序号',
|
||||
},
|
||||
created_at: {
|
||||
type: DATE,
|
||||
allowNull: false,
|
||||
comment: '创建时间',
|
||||
},
|
||||
updated_at: {
|
||||
type: DATE,
|
||||
allowNull: false,
|
||||
comment: '更新时间',
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('exam_questions', ['group'], {
|
||||
name: 'idx_exam_questions_group',
|
||||
});
|
||||
await queryInterface.addIndex('exam_questions', ['group', 'sort_order'], {
|
||||
name: 'idx_exam_questions_group_sort',
|
||||
});
|
||||
},
|
||||
|
||||
down: async (queryInterface) => {
|
||||
await queryInterface.dropTable('exam_questions');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user