Files
starr-philproperties/database/migrations/20270101000010-create-course-prerequisites.js
T

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');
},
};