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:
67
database/migrations/005-create-exam-submissions.js
Normal file
67
database/migrations/005-create-exam-submissions.js
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* 迁移文件:创建答题记录表(exam_submissions)
|
||||
* 存储选手的试卷答题记录
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
const { INTEGER, TEXT, DATE } = Sequelize;
|
||||
|
||||
await queryInterface.createTable('exam_submissions', {
|
||||
id: {
|
||||
type: INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true,
|
||||
allowNull: false,
|
||||
comment: '答题记录唯一标识',
|
||||
},
|
||||
contestant_id: {
|
||||
type: INTEGER,
|
||||
allowNull: false,
|
||||
comment: '选手 ID',
|
||||
references: {
|
||||
model: 'contestants',
|
||||
key: 'id',
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
answers: {
|
||||
type: TEXT,
|
||||
allowNull: false,
|
||||
comment: '答题内容(JSON)',
|
||||
},
|
||||
submit_time: {
|
||||
type: DATE,
|
||||
allowNull: false,
|
||||
comment: '提交时间',
|
||||
},
|
||||
score: {
|
||||
type: INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: null,
|
||||
comment: '试卷得分',
|
||||
},
|
||||
created_at: {
|
||||
type: DATE,
|
||||
allowNull: false,
|
||||
comment: '创建时间',
|
||||
},
|
||||
updated_at: {
|
||||
type: DATE,
|
||||
allowNull: false,
|
||||
comment: '更新时间',
|
||||
},
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('exam_submissions', ['contestant_id'], {
|
||||
name: 'idx_exam_submissions_contestant_id',
|
||||
});
|
||||
},
|
||||
|
||||
down: async (queryInterface) => {
|
||||
await queryInterface.dropTable('exam_submissions');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user