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

class TitleRequirement extends Model { }

TitleRequirement.init({
    id : {
        type: DataTypes.INTEGER,
        allowNull: false,
        primaryKey: true,
        autoIncrement: true},
    titleId: {
        type: DataTypes.INTEGER,
        allowNull: false},
    requirementType: {
        type: DataTypes.STRING,
        allowNull: false},
    requirementValue: {
        type: DataTypes.DECIMAL(14, 2),
        allowNull: false}}, {
    sequelize, 
    modelName: 'TitleRequirement', 
    tableName: 'title_requirement',
    schema: 'falukant_type',
    timestamps: false,
    underscored: true,
    indexes: [
        {
            unique: true,
            fields: ['title_id', 'requirement_type'],
            name: 'title_requirement_titleid_reqtype_unique'
        }
    ]
});

export default TitleRequirement;
