diff options
author | Felipe Artur <felipefac@gmail.com> | 2017-01-27 22:22:17 +0300 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2017-02-14 20:44:13 +0300 |
commit | de12a69a3c33562e7cd4fa81b5e12799a3f68f95 (patch) | |
tree | d2b93572e82040feb60fe871eeae0e55c647acc7 /db/post_migrate | |
parent | 99df355ec2d6a934620254423f2a9451b88c6ab4 (diff) |
Disable invalid service templates
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20170211073944_disable_invalid_service_templates.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/post_migrate/20170211073944_disable_invalid_service_templates.rb b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb new file mode 100644 index 00000000000..84954b1ef64 --- /dev/null +++ b/db/post_migrate/20170211073944_disable_invalid_service_templates.rb @@ -0,0 +1,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 |