From f5fe73559423c881a1a38e69f76a30fd5565b5cd Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Tue, 21 Sep 2021 16:39:02 +0200 Subject: [PATCH] Fixes #3751 - Unable to create new organization. --- ...300_issue_3751_missing_workflow_screens.rb | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb diff --git a/db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb b/db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb new file mode 100644 index 000000000..757ce2bf8 --- /dev/null +++ b/db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb @@ -0,0 +1,30 @@ +# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/ + +class Issue3751MissingWorkflowScreens < ActiveRecord::Migration[5.2] + def change + return if !Setting.exists?(name: 'system_init_done') + + fix_organization_screens_create + fix_user_screens_create + end + + def fix_organization_screens_create + %w[name shared domain_assignment active].each do |name| + field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'Organization')) + field.screens['create'] ||= {} + field.screens['create']['-all-'] ||= {} + field.screens['create']['-all-']['null'] = false + field.save + end + end + + def fix_user_screens_create + %w[firstname lastname active].each do |name| + field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'User')) + field.screens['create'] ||= {} + field.screens['create']['-all-'] ||= {} + field.screens['create']['-all-']['null'] = false + field.save + end + end +end