Sha256: 75100dde9ae50119f17c5be2451f56a1d128d783252742386a0a4e940ed7bd5d
Contents?: true
Size: 1.43 KB
Versions: 27
Compression:
Stored size: 1.43 KB
Contents
require 'openc3/utilities/migration' require 'openc3/models/scope_model' module OpenC3 class LogStuff < Migration def self.run ScopeModel.names.each do |scope| # Get all existing InterfaceModels and change json for log_raw to log_stream # Also remove the log key interface_models = InterfaceModel.all(scope: scope) interface_models.each do |key, model_hash| if model_hash.has_key?('log_raw') if model_hash['log_raw'] model_hash['log_stream'] = [] else model_hash['log_stream'] = nil end if model_hash.has_key?('log') model_hash.delete('log') end model_hash.delete('log_raw') InterfaceModel.from_json(model_hash, scope: scope).update end end router_models = RouterModel.all(scope: scope) router_models.each do |key, model_hash| if model_hash.has_key?('log_raw') if model_hash['log_raw'] model_hash['log_stream'] = [] else model_hash['log_stream'] = nil end if model_hash.has_key?('log') model_hash.delete('log') end model_hash.delete('log_raw') RouterModel.from_json(model_hash, scope: scope).update end end end end end end unless ENV['OPENC3_NO_MIGRATE'] OpenC3::LogStuff.run end
Version data entries
27 entries across 27 versions & 1 rubygems