chore: relocate backend into apps/api ahead of monorepo merge
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/***********************************************************************************************************************************************************************
|
||||
* File Name: course_units.mdl.js
|
||||
* Type of Program: Model (junction)
|
||||
* Description: Attaches a standalone Unit to a Course. A Unit can live in many
|
||||
* Courses; per-course ordering lives here (order_index), not on the
|
||||
* Unit itself. Detaching removes the row — the Unit survives.
|
||||
*
|
||||
* Author: Kenneth Obsequio (@lash0000)
|
||||
* Date Created: Jul. 7, 2026
|
||||
***********************************************************************************************************************************************************************/
|
||||
const { DataTypes } = require("sequelize");
|
||||
const sequelize = require("../../config/db.config");
|
||||
|
||||
const CourseUnit = sequelize.define("CourseUnit", {
|
||||
course_unit_id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
|
||||
course_id: { type: DataTypes.BIGINT, allowNull: false },
|
||||
unit_id: { type: DataTypes.BIGINT, allowNull: false },
|
||||
order_index: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 },
|
||||
createdBy: { type: DataTypes.BIGINT, allowNull: true },
|
||||
updatedBy: { type: DataTypes.BIGINT, allowNull: true },
|
||||
}, {
|
||||
tableName: "course_units",
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ unique: true, fields: ["course_id", "unit_id"], name: "uq_course_units_course_unit" },
|
||||
{ fields: ["course_id"], name: "idx_course_units_course_id" },
|
||||
{ fields: ["unit_id"], name: "idx_course_units_unit_id" },
|
||||
{ fields: ["order_index"], name: "idx_course_units_order" },
|
||||
],
|
||||
});
|
||||
|
||||
module.exports = CourseUnit;
|
||||
Reference in New Issue
Block a user