mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
perform test
test to courses Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.addColumn('users', 'needs_intro', {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false, // existing users skip intro
|
||||
after: 'acc_type',
|
||||
});
|
||||
},
|
||||
down: async (queryInterface) => {
|
||||
await queryInterface.removeColumn('users', 'needs_intro');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('assessment_sessions', {
|
||||
session_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
|
||||
uuid: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, unique: true, allowNull: false },
|
||||
user_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'users', key: 'user_id' }, onDelete: 'CASCADE' },
|
||||
assessment_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'course_assessments', key: 'assessment_id' }, onDelete: 'CASCADE' },
|
||||
course_id: { type: Sequelize.BIGINT, allowNull: true },
|
||||
started_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.NOW },
|
||||
expires_at: { type: Sequelize.DATE, allowNull: true },
|
||||
status: { type: Sequelize.STRING(20), allowNull: false, defaultValue: 'in_progress' },
|
||||
attempt_id: { type: Sequelize.BIGINT, allowNull: true },
|
||||
createdAt: { type: Sequelize.DATE, allowNull: false },
|
||||
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('assessment_sessions', ['user_id'], { name: 'idx_as_user_id' });
|
||||
await queryInterface.addIndex('assessment_sessions', ['assessment_id'], { name: 'idx_as_assessment_id' });
|
||||
await queryInterface.addIndex('assessment_sessions', ['status'], { name: 'idx_as_status' });
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable('assessment_sessions');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
// quiz_attempts.started_at and quiz_attempts.status were added via raw SQL
|
||||
// during an earlier development session. The assessment_sessions table now owns
|
||||
// session lifecycle; quiz_attempts are always-graded completed records only.
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
const tableDesc = await queryInterface.describeTable('quiz_attempts');
|
||||
if (tableDesc.started_at) await queryInterface.removeColumn('quiz_attempts', 'started_at');
|
||||
if (tableDesc.status) await queryInterface.removeColumn('quiz_attempts', 'status');
|
||||
},
|
||||
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('quiz_attempts', 'started_at', { type: Sequelize.DATE, allowNull: true });
|
||||
await queryInterface.addColumn('quiz_attempts', 'status', { type: Sequelize.STRING(20), allowNull: true });
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
const table = await queryInterface.describeTable('assessment_sessions');
|
||||
if (!table.draft_answers)
|
||||
await queryInterface.addColumn('assessment_sessions', 'draft_answers', {
|
||||
type: Sequelize.JSONB, allowNull: true, defaultValue: null,
|
||||
});
|
||||
if (!table.last_heartbeat_at)
|
||||
await queryInterface.addColumn('assessment_sessions', 'last_heartbeat_at', {
|
||||
type: Sequelize.DATE, allowNull: true, defaultValue: null,
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeColumn('assessment_sessions', 'last_heartbeat_at');
|
||||
await queryInterface.removeColumn('assessment_sessions', 'draft_answers');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('pending_certificates', {
|
||||
pending_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
|
||||
user_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'users', key: 'user_id' }, onDelete: 'CASCADE' },
|
||||
course_id: { type: Sequelize.BIGINT, allowNull: false },
|
||||
course_uuid: { type: Sequelize.STRING(36), allowNull: false },
|
||||
course_title: { type: Sequelize.TEXT, allowNull: true },
|
||||
passed_at: { type: Sequelize.DATE, allowNull: false },
|
||||
issue_at: { type: Sequelize.DATE, allowNull: false },
|
||||
processed_at: { type: Sequelize.DATE, allowNull: true },
|
||||
createdAt: { type: Sequelize.DATE, allowNull: false },
|
||||
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('pending_certificates', ['user_id'], { name: 'idx_pc_user_id' });
|
||||
await queryInterface.addIndex('pending_certificates', ['issue_at'], { name: 'idx_pc_issue_at' });
|
||||
await queryInterface.addIndex('pending_certificates', ['processed_at'], { name: 'idx_pc_processed_at' });
|
||||
await queryInterface.addIndex('pending_certificates', ['user_id', 'course_id'], { name: 'idx_pc_user_course', unique: true });
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable('pending_certificates');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user