TradeTariffBackend::DataMigrator.migration do
  name "Remove 0% measures on further cigarette types"

  up do
    applicable {
      Measure::Operation.where(measure_sid: -491538).where(measure_type_id: 'FAA').where(goods_nomenclature_item_id: '2402900000').any?
      Measure::Operation.where(measure_sid: -491539).where(measure_type_id: 'FAA').where(goods_nomenclature_item_id: '2402201000').any?
    }

    apply {
      Measure::Operation.where(measure_sid: -491538).where(measure_type_id: 'FAA').where(goods_nomenclature_item_id: '2402900000').delete
      Measure::Operation.where(measure_sid: -491539).where(measure_type_id: 'FAA').where(goods_nomenclature_item_id: '2402201000').delete
      Measure::Operation.where(measure_sid: -490646).update(validity_end_date: nil)
      Measure::Operation.where(measure_sid: -490647).update(validity_end_date: nil)
    }
  end

  down do
    applicable { false }
    apply {} # noop
  end
end

Add data migration to resolve further 0% measure
Add data migration to resolve further 0% measure

It was reported that the Erga Omnes value for further cigarette
commodities was showing as 0%. Upon investigation we discovered an
incorrect measures had been supplied in the CHIEF file on 28/11/2018,
to resolve this we've implemented a data migration that removes the
incorrect measures and sets the `validity_end_date` on the preceding
ones to NULL to restore them.
