mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
ready to test
Testing Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.createTable('course_reading_progress', {
|
||||
progress_id: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, primaryKey: true },
|
||||
user_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'users', key: 'user_id' }, onDelete: 'CASCADE' },
|
||||
course_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'courses', key: 'course_id' }, onDelete: 'CASCADE' },
|
||||
reference_id: { type: Sequelize.UUID, allowNull: false },
|
||||
type: { type: Sequelize.ENUM('course', 'unit', 'lesson'), allowNull: false },
|
||||
status: { type: Sequelize.ENUM('in_progress', 'completed'), allowNull: false, defaultValue: 'in_progress' },
|
||||
completed_at: { type: Sequelize.DATE, allowNull: true },
|
||||
last_accessed_at: { type: Sequelize.DATE, allowNull: false, defaultValue: Sequelize.literal('CURRENT_TIMESTAMP') },
|
||||
createdBy: { type: Sequelize.BIGINT, allowNull: true },
|
||||
updatedBy: { type: Sequelize.BIGINT, allowNull: true },
|
||||
createdAt: { type: Sequelize.DATE, allowNull: false },
|
||||
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('course_reading_progress', {
|
||||
fields: ['user_id', 'type', 'reference_id'],
|
||||
unique: true,
|
||||
name: 'uq_crp_user_type_reference',
|
||||
});
|
||||
|
||||
await queryInterface.addIndex('course_reading_progress', { fields: ['user_id'], name: 'idx_crp_user_id' });
|
||||
await queryInterface.addIndex('course_reading_progress', { fields: ['course_id'], name: 'idx_crp_course_id' });
|
||||
await queryInterface.addIndex('course_reading_progress', { fields: ['type'], name: 'idx_crp_type' });
|
||||
await queryInterface.addIndex('course_reading_progress', { fields: ['status'], name: 'idx_crp_status' });
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.dropTable('course_reading_progress');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user