Class: OnlineMigrations::DataMigrations::BackfillDoNotMergeOnElectricalSpecs
- Inherits:
-
OnlineMigrations::DataMigration
- Object
- OnlineMigrations::DataMigration
- OnlineMigrations::DataMigrations::BackfillDoNotMergeOnElectricalSpecs
- Defined in:
- lib/online_migrations/data_migrations/backfill_do_not_merge_on_electrical_specs.rb
Overview
Sets legacy_do_not_merge = true on every existing product_specifications
row whose token is in Models::ItemSpecificationHelper::PER_ITEM_SPEC_TOKENS
(watts, voltage, amps, ohms).
HISTORICAL — completed in production on 2026-05-07. Kept only so the
migration chain stays replayable; it describes a world that no longer
exists.
Background as it stood then:
Maintenance::ItemMaintenance#consolidate_specs ran nightly and
collapsed any rows whose (token, grouping, sku_regexp, method, text_blurb, units, image_id, formatter) tuple matched into a single
row — unless the merge opt-out was set. For tokens whose values
coincidentally match across unrelated SKUs (a 175W cable kit and a
175W towel warmer are not "the same spec"), that collapse silently
welded independent items into a shared row. Editing one then mutated
the others. create_or_set_spec_value set the flag for these tokens at
write time, and this migration backfilled it onto pre-existing rows.
Since #1856 the consolidator is gone, no application code writes
legacy_do_not_merge, and nothing reads it — this class and its two
siblings are the only remaining references.
Constant Summary collapse
- BATCH_SIZE =
1_000- TOKENS =
Models::ItemSpecificationHelper::PER_ITEM_SPEC_TOKENS.map(&:to_s).freeze
Delegated Instance Attributes collapse
-
#count ⇒ Integer
Number of rows that still need the flag flipped.
Instance Method Summary collapse
-
#collection ⇒ ActiveRecord::Batches::BatchEnumerator
Yields batches of
ProductSpecificationrows that still need the flag flipped. -
#process(specs) ⇒ void
Flips
legacy_do_not_mergeto true on every row in the batch via a singleupdate_all(no callbacks — this is a flag-only change).
Instance Method Details
#collection ⇒ ActiveRecord::Batches::BatchEnumerator
Yields batches of ProductSpecification rows that still need the
flag flipped.
39 40 41 |
# File 'lib/online_migrations/data_migrations/backfill_do_not_merge_on_electrical_specs.rb', line 39 def collection candidate_relation.in_batches(of: BATCH_SIZE) end |
#count ⇒ Integer
Number of rows that still need the flag flipped. Used by
online_migrations for progress reporting.
60 |
# File 'lib/online_migrations/data_migrations/backfill_do_not_merge_on_electrical_specs.rb', line 60 delegate :count, to: :candidate_relation |
#process(specs) ⇒ void
This method returns an undefined value.
Flips legacy_do_not_merge to true on every row in the batch via a single
update_all (no callbacks — this is a flag-only change).
50 51 52 |
# File 'lib/online_migrations/data_migrations/backfill_do_not_merge_on_electrical_specs.rb', line 50 def process(specs) specs.update_all(legacy_do_not_merge: true) end |