Disable invalid service templates (again)

This commit is contained in:
Sean McGivern 2017-03-30 15:38:05 +01:00
parent 6185429495
commit 8af788e085
2 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
title: Disable invalid service templates
merge_request:
author:

View File

@ -0,0 +1,18 @@
# This is the same as DisableInvalidServiceTemplates. Later migrations may have
# inadventently enabled some invalid templates again.
#
class DisableInvalidServiceTemplates2 < 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