20170211073944_disable_invalid_service_templates.rb 354 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class DisableInvalidServiceTemplates < ActiveRecord::Migration
  DOWNTIME = false

  unless defined?(Service)
    class Service < ActiveRecord::Base
      self.inheritance_column = nil
    end
  end

  def up
    Service.where(template: true, active: true).each do |template|
      template.update(active: false) unless template.valid?
    end
  end
end