import { Model, DataTypes } from 'sequelize';
import { sequelize } from '../../utils/sequelize.js';

class VocabCourseProgress extends Model {}

VocabCourseProgress.init({
    id: {
        type: DataTypes.INTEGER,
        primaryKey: true,
        autoIncrement: true
    },
    userId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        field: 'user_id'
    },
    courseId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        field: 'course_id'
    },
    lessonId: {
        type: DataTypes.INTEGER,
        allowNull: false,
        field: 'lesson_id'
    },
    completed: {
        type: DataTypes.BOOLEAN,
        allowNull: false,
        defaultValue: false
    },
    score: {
        type: DataTypes.INTEGER,
        allowNull: false,
        defaultValue: 0
    },
    lastAccessedAt: {
        type: DataTypes.DATE,
        allowNull: true,
        field: 'last_accessed_at'
    },
    completedAt: {
        type: DataTypes.DATE,
        allowNull: true,
        field: 'completed_at'
    }
}, {
    sequelize,
    modelName: 'VocabCourseProgress',
    tableName: 'vocab_course_progress',
    schema: 'community',
    timestamps: false,
    underscored: true
});

export default VocabCourseProgress;
