const { DataTypes } = require("sequelize");
const sequelize = require("../db");

const TrainingCourseEnrollment = sequelize.define("TrainingCourseEnrollment", {
  status: {
    type: DataTypes.ENUM("not-started", "in-progress", "completed", "failed"),
    defaultValue: "not-started",
  },
  enrolledAt: {
    type: DataTypes.DATE,
    defaultValue: DataTypes.NOW,
  },
  completedAt: {
    type: DataTypes.DATE,
  },
  certificateId: {
    type: DataTypes.STRING,
  },
  overallScore: {
    type: DataTypes.INTEGER,
    comment: "Average score across all modules",
  },
  // UserId and TrainingCourseId added via associations
}, {
  freezeTableName: true,
  tableName: 'TrainingCourseEnrollments'
});

module.exports = TrainingCourseEnrollment;
