Skip to content

Commit

Permalink
fix migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmelt committed Dec 9, 2024
1 parent 8e7b172 commit ba6e551
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 33 deletions.
2 changes: 1 addition & 1 deletion openc3/bin/openc3cli
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def run_migrations(folder)
if !folder
folder = "/openc3/lib/openc3/migrations"
entries = Dir.entries(folder).map { |entry| File.join(folder, entry) }
folder = "/openc3-enterprise/lib/openc3/migrations"
folder = "/openc3-enterprise/lib/openc3-enterprise/migrations"
if File.exist?(folder)
entries.concat(Dir.entries(folder).map { |entry| File.join(folder, entry) })
end
Expand Down
29 changes: 0 additions & 29 deletions openc3/lib/openc3/migrations/20241107120000_no_trigger_group.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ class NoCriticalCmd < Migration
end

def self.run
if BASE # Only remove the critical command model if we're not enterprise
ScopeModel.get_all_models(scope: nil).each do |scope, scope_model|
model = MicroserviceModel.get_model(name: "#{scope}__CRITICALCMD__#{scope}", scope: scope)
ScopeModel.get_all_models(scope: nil).each do |scope, scope_model|
model = MicroserviceModel.get_model(name: "#{scope}__CRITICALCMD__#{scope}", scope: scope)
if BASE # Only remove the critical command model if we're not enterprise
model.destroy if model
else
model.work_dir = '/openc3-enterprise/lib/openc3-enterprise/microservices'
model.update
end
end
end
Expand Down
46 changes: 46 additions & 0 deletions openc3/lib/openc3/migrations/20241208080001_no_trigger_group.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'openc3/utilities/migration'
require 'openc3/models/scope_model'
require 'openc3/models/microservice_model'

module OpenC3
class NoTriggerGroups < Migration
begin
require 'openc3-enterprise/models/cmd_authority_model'
require 'openc3-enterprise/models/critical_cmd_model'
BASE = false
rescue LoadError
BASE = true
end

def self.run
MicroserviceModel.get_all_models(scope: 'DEFAULT').each do |microservice_name, microservice_model|
if microservice_name =~ /__TRIGGER_GROUP__/
if BASE
# Only remove the trigger group microservice if we're not enterprise
microservice_model.destroy
else
# Need to update working dir for Enterprise
microservice_model.work_dir = '/openc3-enterprise/lib/openc3-enterprise/microservices'
microservice_model.update
end
end

if microservice_name =~ /__OPENC3__REACTION/
# Need to update working dir for Enterprise
microservice_model.work_dir = '/openc3-enterprise/lib/openc3-enterprise/microservices'
microservice_model.update
end

if microservice_name =~ /__TIMELINE__/
# Need to update working dir for Enterprise
microservice_model.work_dir = '/openc3-enterprise/lib/openc3-enterprise/microservices'
microservice_model.update
end
end
end
end
end

unless ENV['OPENC3_NO_MIGRATE']
OpenC3::NoTriggerGroups.run
end

0 comments on commit ba6e551

Please sign in to comment.