From 505c17e3112d02f7793b5fa387312ab20eee6a30 Mon Sep 17 00:00:00 2001 From: Ryan Melton Date: Wed, 16 Oct 2024 22:19:54 -0600 Subject: [PATCH] Add critical cmd migration --- .../20241016000000_scope_critical_cmd.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 openc3/lib/openc3/migrations/20241016000000_scope_critical_cmd.rb diff --git a/openc3/lib/openc3/migrations/20241016000000_scope_critical_cmd.rb b/openc3/lib/openc3/migrations/20241016000000_scope_critical_cmd.rb new file mode 100644 index 000000000..b6e82de0d --- /dev/null +++ b/openc3/lib/openc3/migrations/20241016000000_scope_critical_cmd.rb @@ -0,0 +1,21 @@ +require 'openc3/utilities/migration' +require 'openc3/models/scope_model' + +module OpenC3 + class ScopeCriticalCmd < Migration + def self.run + ScopeModel.names.each do |scope| + scope_model = ScopeModel.get_model(name: scope) + parent = "#{scope}__SCOPEMULTI__#{scope}" + scope_model.deploy_critical_cmd_microservice("/notexist", {}, parent) + microservice_model = MicroserviceModel.get_model(name: parent, scope: scope) + microservice_model.cmd << "#{scope}__CRITICALCMD__#{scope}" + microservice_model.update + end + end + end +end + +unless ENV['OPENC3_NO_MIGRATE'] + OpenC3::ScopeCriticalCmd.run +end