module.exports = (sequelize, DataTypes) => {
  const DimensionalReportDetail = sequelize.define('DimensionalReportDetail', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    report_id: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    line_no: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    description: {
      type: DataTypes.STRING(200),
      allowNull: false
    },
    drg_dim: {
      type: DataTypes.STRING(100),
      allowNull: true
    },
    tol: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    reading_1: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    reading_2: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    reading_3: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    reading_4: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    reading_5: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    no_of_rew: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    no_of_rej: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    laser_turret: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    remarks: {
      type: DataTypes.TEXT,
      allowNull: true
    }
  }, {
    tableName: 'dimensional_report_detail',
    underscored: true,
    timestamps: true,
    createdAt: 'created_at',
    updatedAt: 'updated_at'
  });

  DimensionalReportDetail.associate = function(models) {
    DimensionalReportDetail.belongsTo(models.DimensionalReport, {
      foreignKey: 'report_id',
      as: 'header'
    });
  };

  return DimensionalReportDetail;
};
