summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-02-15 12:10:28 +0000
committerRuben Davila <rdavila84@gmail.com>2017-02-27 23:53:04 -0500
commitb85f7a741751badcb377d87284a30364555f6550 (patch)
tree590d3b65ebcda21c72f685b72954a8e17351021f
parentb57e8a4f4c329ff646bc906d3592a636f94163d6 (diff)
downloadgitlab-ce-b85f7a741751badcb377d87284a30364555f6550.tar.gz
Merge branch 'issue_25112' into 'master'
Disable invalid service templates Closes #25112 See merge request !8850 Conflicts: db/schema.rb
-rw-r--r--changelogs/unreleased/issue_25112.yml4
-rw-r--r--db/post_migrate/20170211073944_disable_invalid_service_templates.rb15
2 files changed, 19 insertions, 0 deletions
diff --git a/changelogs/unreleased/issue_25112.yml b/changelogs/unreleased/issue_25112.yml
new file mode 100644
index 00000000000..c43d2732b9a
--- /dev/null
+++ b/changelogs/unreleased/issue_25112.yml
@@ -0,0 +1,4 @@
+---
+title: Disable invalid service templates
+merge_request:
+author:
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