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

/**
 * Vacation Model
 * Repräsentiert die vacation-Tabelle
 */
class Vacation extends Model {
  static initialize(sequelize) {
    Vacation.init(
      {
        id: {
          type: DataTypes.BIGINT,
          primaryKey: true,
          autoIncrement: true,
          allowNull: false
        },
        version: {
          type: DataTypes.INTEGER,
          allowNull: false,
          defaultValue: 0
        },
        user_id: {
          type: DataTypes.BIGINT,
          allowNull: false,
          references: {
            model: 'user',
            key: 'id'
          }
        },
        first_day: {
          type: DataTypes.DATEONLY,
          allowNull: true
        },
        last_day: {
          type: DataTypes.DATEONLY,
          allowNull: true
        },
        vacation_type: {
          type: DataTypes.INTEGER,
          allowNull: false,
          defaultValue: 0
        }
      },
      {
        sequelize,
        tableName: 'vacation',
        timestamps: false,
        indexes: [
          {
            name: 'fk_vacation_user',
            fields: ['user_id']
          }
        ]
      }
    );

    return Vacation;
  }
}

module.exports = Vacation;



