6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/openc3/migrations/20221202214600_add_target_names.rb', line 6
def self.run
ScopeModel.names.each do |scope|
interface_models = InterfaceModel.all(scope: scope)
interface_models.each do |key, model_hash|
target_names = model_hash['target_names']
model_hash['cmd_target_names'] = target_names unless model_hash['cmd_target_names']
model_hash['tlm_target_names'] = target_names unless model_hash['tlm_target_names']
InterfaceModel.from_json(model_hash, scope: scope).update
end
router_models = RouterModel.all(scope: scope)
router_models.each do |key, model_hash|
target_names = model_hash['target_names']
model_hash['cmd_target_names'] = target_names unless model_hash['cmd_target_names']
model_hash['tlm_target_names'] = target_names unless model_hash['tlm_target_names']
RouterModel.from_json(model_hash, scope: scope).update
end
end
end
|