mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
29 lines
1.6 KiB
JavaScript
29 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
await queryInterface.createTable('quiz_attempts', {
|
|
attempt_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
|
|
uuid: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, unique: true },
|
|
user_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'users', key: 'user_id' }, onDelete: 'CASCADE' },
|
|
quiz_id: { type: Sequelize.BIGINT, allowNull: true, references: { model: 'unit_quizzes', key: 'quiz_id' }, onDelete: 'SET NULL' },
|
|
assessment_id: { type: Sequelize.BIGINT, allowNull: true, references: { model: 'course_assessments', key: 'assessment_id' }, onDelete: 'SET NULL' },
|
|
answers: { type: Sequelize.JSONB, allowNull: false, defaultValue: {} },
|
|
total_points: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
|
earned_points: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
|
score: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
|
|
passed: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: false },
|
|
createdAt: { type: Sequelize.DATE, allowNull: false },
|
|
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
|
});
|
|
|
|
await queryInterface.addIndex('quiz_attempts', ['user_id']);
|
|
await queryInterface.addIndex('quiz_attempts', ['quiz_id']);
|
|
await queryInterface.addIndex('quiz_attempts', ['assessment_id']);
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
await queryInterface.dropTable('quiz_attempts');
|
|
},
|
|
};
|