aboutsummaryrefslogtreecommitdiffstats
path: root/db/migrate/20180306152953_update_imports_names.rb
blob: fc57ff84981b7de1810662564337d23e25be9da2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
class UpdateImportsNames < ActiveRecord::Migration
  def change
    Import::Base.all.pluck(:type).uniq.each do |type|
      next if type =~ /^Import/
      Import::Base.where(type: type).update_all type: "Import::#{type.gsub 'Import', ''}"
    end

    Import::Base.all.pluck(:parent_type).uniq.compact.each do |type|
      next if type =~ /^Import/
      Import::Base.where(parent_type: type).update_all parent_type: "Import::#{type.gsub 'Import', ''}"
    end
  end
end