Sha256: e5e9cb66ccdf3cafc2780158e6742c775558ae404c088ac12e271560e7e733fb
Contents?: true
Size: 1.15 KB
Versions: 6
Compression:
Stored size: 1.15 KB
Contents
class RemoveAntecedentsFromVersionsOfTickets < ActiveRecord::Migration[5.0] include VestalVersions def up versions = Version.where("modifications like '%!ruby/object:TicketAntecedent%'") pbar = ProgressBar.new("progress", versions.count) versions.pluck(:id, :modifications).each do |id, modifications| new_modifications = modifications.except("antecedents") if new_modifications.empty? Version.where(id: id).delete_all else Version.where(id: id).update_all(modifications: new_modifications) end pbar.inc end pbar.finish versions = Version.where("modifications like '%!ruby/object:TicketTag%'") pbar = ProgressBar.new("progress", versions.count) versions.pluck(:id, :modifications).each do |id, modifications| change = modifications["tags"] new_modifications = modifications.merge("tags" => [change[0].map(&:to_s), change[1].map(&:to_s)]) Version.where(id: id).update_all(modifications: new_modifications) pbar.inc end pbar.finish end end class TicketAntecedent; end class TicketTag attr_reader :name, :color def to_s "[#{name}](#{color})" end end
Version data entries
6 entries across 6 versions & 1 rubygems