updated db migration

This commit is contained in:
2026-07-20 12:28:46 +08:00
parent a2c9936f79
commit d665897ef5
129 changed files with 574 additions and 1878 deletions
@@ -0,0 +1,36 @@
'use strict';
// The live enum type backing `type` is named task_requirement_type (not the
// Sequelize-default enum_task_requirements_type) — submit_text/pass_quiz were
// added to it later via ALTER TYPE (20260715000001). Declared here with the
// full merged value set.
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('task_requirements', {
requirement_id: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, primaryKey: true },
task_id: { type: Sequelize.UUID, allowNull: false, references: { model: 'tasks', key: 'task_id' }, onDelete: 'CASCADE' },
type: { type: Sequelize.ENUM('visit_link', 'upload_file', 'read_course', 'read_unit', 'read_lesson', 'submit_text', 'pass_quiz'), allowNull: false },
link_url: { type: Sequelize.STRING, allowNull: true },
link_label: { type: Sequelize.STRING, allowNull: true },
allowed_file_types: { type: Sequelize.JSONB, allowNull: true },
max_file_count: { type: Sequelize.INTEGER, allowNull: true, defaultValue: 1 },
reference_id: { type: Sequelize.UUID, allowNull: true },
reference_label: { type: Sequelize.STRING, allowNull: true },
prompt: { type: Sequelize.TEXT, allowNull: true },
requires_review: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: false },
order: { type: Sequelize.INTEGER, defaultValue: 0 },
createdBy: { type: Sequelize.INTEGER, allowNull: true },
updatedBy: { type: Sequelize.INTEGER, allowNull: true },
deletedBy: { type: Sequelize.INTEGER, allowNull: true },
createdAt: { type: Sequelize.DATE, allowNull: false },
updatedAt: { type: Sequelize.DATE, allowNull: false },
deletedAt: { type: Sequelize.DATE, allowNull: true },
});
await queryInterface.addIndex('task_requirements', ['task_id']);
},
async down(queryInterface) {
await queryInterface.dropTable('task_requirements');
},
};