Class: OnlineMigrations::BackgroundMigrations::UpdateSnowMeltMatArticleUrls
- Inherits:
-
OnlineMigrations::BackgroundMigration
- Object
- OnlineMigrations::BackgroundMigration
- OnlineMigrations::BackgroundMigrations::UpdateSnowMeltMatArticleUrls
- Defined in:
- lib/online_migrations/background_migrations/update_snow_melt_mat_article_urls.rb
Overview
Background migration to update article solution URLs from old snow-melting-mat
product line to the new snowmelt-powermat product line.
Enqueued by: 20251223190000_enqueue_update_snow_melt_mat_article_urls.rb
This migration updates article.solution text replacing:
/products/line/snow-melting-mat -> /products/line/snowmelt-powermat
The old parent "Mat" product line (ID 40, URL snow-melting-mat) has been split into
three sub-product lines: PowerMat, OmniMat, and EcoMat. PowerMat is the default
product for existing references.
Constant Summary collapse
- OLD_URL =
'/products/line/snow-melting-mat'- NEW_URL =
'/products/line/snowmelt-powermat'
Instance Method Summary collapse
Instance Method Details
#count ⇒ Object
32 33 34 |
# File 'lib/online_migrations/background_migrations/update_snow_melt_mat_article_urls.rb', line 32 def count Article.where('solution ILIKE ?', "%#{OLD_URL}%").count end |
#process_batch(articles) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/online_migrations/background_migrations/update_snow_melt_mat_article_urls.rb', line 25 def process_batch(articles) articles.each do |article| new_solution = article.solution.gsub(OLD_URL, NEW_URL) article.update_column(:solution, new_solution) end end |