const { DataTypes } = require('sequelize');

module.exports = (sequelize) => {
    const Progression = sequelize.define('progression', {
        id: {
            type: DataTypes.INTEGER,
            autoIncrement: true,
            primaryKey: true
        },
        scope_development: { type: DataTypes.STRING, allowNull: true },
        achievement_detail: { type: DataTypes.TEXT, allowNull: true },
        achievement_level: { type: DataTypes.STRING, allowNull: true },

        // fk
        course_id: {
            type: DataTypes.INTEGER,
            references: {
                model: 'courses',
                key: 'id'
            }
        },
    }, {
        tableName: 'progressions',
        freezeTableName: true
    });

    Progression.associate = (models) => {
        Progression.belongsTo(models.Course, { foreignKey: 'course_id', as: 'course' });
    };


    return Progression;
};

