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

/**
 * WeeklyWorktime Model
 * Repräsentiert die weekly_worktime-Tabelle
 */
class WeeklyWorktime extends Model {
  static initialize(sequelize) {
    WeeklyWorktime.init(
      {
        id: {
          type: DataTypes.INTEGER,
          primaryKey: true,
          autoIncrement: true,
          allowNull: false
        },
        weekly_work_time: {
          type: DataTypes.DOUBLE,
          allowNull: false,
          defaultValue: 40
        },
        starting_from: {
          type: DataTypes.DATEONLY,
          allowNull: true
        },
        ends_at: {
          type: DataTypes.DATEONLY,
          allowNull: true
        },
        user_id: {
          type: DataTypes.INTEGER,
          allowNull: true,
          references: {
            model: 'user',
            key: 'id'
          }
        },
        version: {
          type: DataTypes.INTEGER,
          allowNull: false,
          defaultValue: 0
        }
      },
      {
        sequelize,
        tableName: 'weekly_worktime',
        timestamps: false
      }
    );

    return WeeklyWorktime;
  }
}

module.exports = WeeklyWorktime;



