From 07c6bdacfb194181525d1cd08eeebec216063398 Mon Sep 17 00:00:00 2001 From: Rolf Schmidt Date: Fri, 1 Oct 2021 12:25:06 +0200 Subject: [PATCH] Fixes #3781 - ObjectManager Attribute without screen attribute causes CoreWorkflows migration to fail --- db/migrate/20210128131507_init_core_workflow.rb | 6 ++++++ .../20210921112300_issue_3751_missing_workflow_screens.rb | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/db/migrate/20210128131507_init_core_workflow.rb b/db/migrate/20210128131507_init_core_workflow.rb index ad4782b78..1c29a9e13 100644 --- a/db/migrate/20210128131507_init_core_workflow.rb +++ b/db/migrate/20210128131507_init_core_workflow.rb @@ -75,6 +75,8 @@ class InitCoreWorkflow < ActiveRecord::Migration[5.2] def fix_pending_time pending_time = ObjectManager::Attribute.find_by(name: 'pending_time', object_lookup: ObjectLookup.find_by(name: 'Ticket')) + return if pending_time.blank? + pending_time.data_option.delete('required_if') pending_time.data_option.delete('shown_if') pending_time.save @@ -83,6 +85,8 @@ class InitCoreWorkflow < ActiveRecord::Migration[5.2] def fix_organization_screens %w[domain note].each do |name| field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'Organization')) + next if field.blank? + field.screens['create'] ||= {} field.screens['create']['-all-'] ||= {} field.screens['create']['-all-']['null'] = true @@ -93,6 +97,8 @@ class InitCoreWorkflow < ActiveRecord::Migration[5.2] def fix_user_screens %w[email web phone mobile organization_id fax department street zip city country address password vip note role_ids].each do |name| field = ObjectManager::Attribute.find_by(name: name, object_lookup: ObjectLookup.find_by(name: 'User')) + next if field.blank? + field.screens['create'] ||= {} field.screens['create']['-all-'] ||= {} field.screens['create']['-all-']['null'] = true diff --git a/db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb b/db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb index f1eaade52..aae63c2b5 100644 --- a/db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb +++ b/db/migrate/20210921112300_issue_3751_missing_workflow_screens.rb @@ -11,6 +11,8 @@ class Issue3751MissingWorkflowScreens < ActiveRecord::Migration[6.0] 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')) + next if field.blank? + field.screens['create'] ||= {} field.screens['create']['-all-'] ||= {} field.screens['create']['-all-']['null'] = false @@ -21,6 +23,8 @@ class Issue3751MissingWorkflowScreens < ActiveRecord::Migration[6.0] 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')) + next if field.blank? + field.screens['create'] ||= {} field.screens['create']['-all-'] ||= {} field.screens['create']['-all-']['null'] = false