module.exports = (sequelize, DataTypes) => {
  const WeldingVisualInspectionReportDetail = sequelize.define('WeldingVisualInspectionReportDetail', {
    id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
    wvir_id: { type: DataTypes.INTEGER, allowNull: false },
    line_no: { type: DataTypes.INTEGER, allowNull: false },
    sub_part_code: { type: DataTypes.STRING(120), allowNull: true },
    sub_part_name: { type: DataTypes.STRING(250), allowNull: true },
    qty: { type: DataTypes.DECIMAL(18, 3), allowNull: true, defaultValue: 0 },
    sample_1: { type: DataTypes.STRING(20), allowNull: true },
    sample_2: { type: DataTypes.STRING(20), allowNull: true },
    sample_3: { type: DataTypes.STRING(20), allowNull: true },
    sample_4: { type: DataTypes.STRING(20), allowNull: true },
    sample_5: { type: DataTypes.STRING(20), allowNull: true },
    sample_6: { type: DataTypes.STRING(20), allowNull: true },
    sample_7: { type: DataTypes.STRING(20), allowNull: true },
    sample_8: { type: DataTypes.STRING(20), allowNull: true },
    sample_9: { type: DataTypes.STRING(20), allowNull: true },
    sample_10: { type: DataTypes.STRING(20), allowNull: true },
    remark: { type: DataTypes.STRING(255), allowNull: true },
    line_status: { type: DataTypes.STRING(30), allowNull: true }
  }, {
    tableName: 'welding_visual_inspection_report_detail',
    underscored: true,
    timestamps: true,
    createdAt: 'created_at',
    updatedAt: 'updated_at'
  });

  WeldingVisualInspectionReportDetail.associate = function(models) {
    WeldingVisualInspectionReportDetail.belongsTo(models.WeldingVisualInspectionReport, { foreignKey: 'wvir_id', as: 'header' });
  };

  return WeldingVisualInspectionReportDetail;
};

