@@ -4,6 +4,7 @@ module Runtimes
44 module FlowTypes
55 class UpdateService
66 include Sagittarius ::Database ::Transactional
7+ include Code0 ::ZeroTrack ::Loggable
78
89 attr_reader :current_runtime , :flow_types
910
@@ -18,14 +19,25 @@ def execute
1819 FlowType . where ( runtime : current_runtime ) . update_all ( removed_at : Time . zone . now )
1920 # rubocop:enable Rails/SkipsModelValidations
2021 flow_types . each do |flow_type |
21- unless update_flowtype ( flow_type , t )
22- t . rollback_and_return! ServiceResponse . error ( message : 'Failed to update flow type' ,
23- payload : flow_type . errors )
24- end
22+ db_flow_type = update_flowtype ( flow_type , t )
23+ next if db_flow_type . persisted?
24+
25+ logger . error (
26+ message : 'Failed to update flow type' ,
27+ runtime_id : current_runtime . id ,
28+ flow_type_identifier : flow_type . identifier ,
29+ errors : db_flow_type . errors . full_messages
30+ )
31+
32+ t . rollback_and_return! ServiceResponse . error ( message : 'Failed to update flow type' ,
33+ error_code : :invalid_flow_type ,
34+ details : db_flow_type . errors )
2535 end
2636
2737 UpdateRuntimeCompatibilityJob . perform_later ( { runtime_id : current_runtime . id } )
2838
39+ logger . info ( message : 'Updated flow types for runtime' , runtime_id : current_runtime . id )
40+
2941 ServiceResponse . success ( message : 'Updated data types' , payload : flow_types )
3042 end
3143 end
@@ -49,6 +61,7 @@ def update_flowtype(flow_type, t)
4961 db_object . aliases = update_translations ( flow_type . alias , db_object . aliases )
5062 db_object . version = "#{ flow_type . version . major } .#{ flow_type . version . minor } .#{ flow_type . version . patch } "
5163 db_object . save
64+ db_object
5265 end
5366
5467 def find_datatype ( identifier , t )
0 commit comments