mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
22 lines
896 B
JavaScript
22 lines
896 B
JavaScript
'use strict';
|
|
|
|
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
await queryInterface.createTable('course_prerequisites', {
|
|
prereq_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
|
|
course_id: { type: Sequelize.BIGINT, allowNull: false, references: { model: 'courses', key: 'course_id' }, onDelete: 'CASCADE' },
|
|
ref_type: { type: Sequelize.ENUM('course', 'unit', 'lesson'), allowNull: false },
|
|
ref_id: { type: Sequelize.BIGINT, allowNull: false },
|
|
order_index: { type: Sequelize.INTEGER, defaultValue: 0 },
|
|
createdAt: { type: Sequelize.DATE, allowNull: false },
|
|
updatedAt: { type: Sequelize.DATE, allowNull: false },
|
|
});
|
|
|
|
await queryInterface.addIndex('course_prerequisites', ['course_id']);
|
|
},
|
|
|
|
async down(queryInterface) {
|
|
await queryInterface.dropTable('course_prerequisites');
|
|
},
|
|
};
|