diff --git a/changelogs/unreleased/issue_25112.yml b/changelogs/unreleased/issue_25112.yml new file mode 100644 index 0000000000000000000000000000000000000000..c43d2732b9acfc331cce20b71fc386430999c37d --- /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/20170208170548_disable_invalid_service_templates.rb b/db/post_migrate/20170208170548_disable_invalid_service_templates.rb new file mode 100644 index 0000000000000000000000000000000000000000..fe369b74c7313e195eb871f6980530af803cf93b --- /dev/null +++ b/db/post_migrate/20170208170548_disable_invalid_service_templates.rb @@ -0,0 +1,15 @@ +class DisableInvalidServiceTemplates < ActiveRecord::Migration + DOWNTIME = false + + if defined?(Service).nil? + 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 diff --git a/db/schema.rb b/db/schema.rb index 7b99a9808741610bba9ea61874f6eecc4eba9efa..755537803fd91ec64c6f4516b512f234e4b83cf7 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170207150212) do +ActiveRecord::Schema.define(version: 20170208170548) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql"