module.exports = (sequelize, DataTypes) => {
  const AssemblyFinalInspectionReportDetail = sequelize.define('AssemblyFinalInspectionReportDetail', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    report_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: { model: 'AssemblyFinalInspectionReport', key: 'id' },
      onDelete: 'CASCADE'
    },
    line_no: {
      type: DataTypes.INTEGER,
      allowNull: false,
      comment: 'Sl No.'
    },
    item_description: {
      type: DataTypes.STRING(500),
      allowNull: true,
      comment: 'Item Description'
    },
    specification: {
      type: DataTypes.STRING(300),
      allowNull: true,
      comment: 'Specification'
    },
    qty_per_set: {
      type: DataTypes.DECIMAL(15, 3),
      allowNull: true,
      comment: 'Qty/Set'
    },
    frame_1: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 1 result' },
    frame_2: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 2 result' },
    frame_3: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 3 result' },
    frame_4: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 4 result' },
    frame_5: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 5 result' },
    frame_6: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 6 result' },
    frame_7: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 7 result' },
    frame_8: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 8 result' },
    frame_9: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 9 result' },
    frame_10: { type: DataTypes.STRING(50), allowNull: true, comment: 'Frame 10 result' }
  }, {
    tableName: 'assembly_final_inspection_report_detail',
    underscored: true,
    timestamps: false,
    indexes: [
      { fields: ['report_id'] },
      { fields: ['line_no'] }
    ]
  });

  AssemblyFinalInspectionReportDetail.associate = function(models) {
    AssemblyFinalInspectionReportDetail.belongsTo(models.AssemblyFinalInspectionReport, { foreignKey: 'report_id', as: 'report' });
  };

  return AssemblyFinalInspectionReportDetail;
};
