module.exports = (sequelize, DataTypes) => {
  const WeldingFinalInspectionReportDetail = sequelize.define('WeldingFinalInspectionReportDetail', {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    wfir_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        model: 'WeldingFinalInspectionReport',
        key: 'id'
      }
    },
    line_no: {
      type: DataTypes.INTEGER,
      allowNull: false
    },
    description: {
      type: DataTypes.STRING(500),
      allowNull: true,
      comment: 'Inspection Parameter Description'
    },
    qty: {
      type: DataTypes.STRING(50),
      allowNull: true,
      comment: 'Quantity/Specification'
    },
    frame_1: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_2: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_3: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_4: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_5: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_6: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_7: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_8: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_9: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_10: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_11: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_12: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_13: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_14: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_15: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_16: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_17: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_18: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_19: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    frame_20: {
      type: DataTypes.STRING(50),
      allowNull: true
    },
    remarks: {
      type: DataTypes.TEXT,
      allowNull: true
    }
  }, {
    tableName: 'welding_final_inspection_report_detail',
    underscored: true,
    timestamps: true,
    createdAt: 'created_at',
    updatedAt: 'updated_at',
    indexes: [
      { fields: ['wfir_id'] },
      { unique: true, fields: ['wfir_id', 'line_no'] }
    ]
  });

  WeldingFinalInspectionReportDetail.associate = function(models) {
    WeldingFinalInspectionReportDetail.belongsTo(models.WeldingFinalInspectionReport, {
      foreignKey: 'wfir_id',
      as: 'header'
    });
  };

  return WeldingFinalInspectionReportDetail;
};
