Skip to content

Commit

Permalink
Add db host and tenant in restore sap system command
Browse files Browse the repository at this point in the history
  • Loading branch information
CDimonaco committed Mar 21, 2024
1 parent 22c54cd commit 3b74416
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ defmodule Trento.Infrastructure.Commanded.EventHandlers.DatabaseRestoreEventHand
)
)

for %{id: sap_system_id} <- database.sap_systems do
for %{id: sap_system_id, tenant: tenant, db_host: db_host} <- database.sap_systems do
Logger.info("Restoring sap system: #{sap_system_id} attached to database: #{database_id}")

commanded().dispatch(
%RestoreSapSystem{sap_system_id: sap_system_id},
%RestoreSapSystem{sap_system_id: sap_system_id, db_host: db_host, tenant: tenant},
consistency: :strong
)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/trento/sap_systems/commands/restore_sap_system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ defmodule Trento.SapSystems.Commands.RestoreSapSystem do

defcommand do
field :sap_system_id, Ecto.UUID
field :db_host, :string
field :tenant, :string
end
end
4 changes: 3 additions & 1 deletion lib/trento/sap_systems/sap_system.ex
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,13 @@ defmodule Trento.SapSystems.SapSystem do
# Restore a SAP system when the restore command is received, check for the required instances
defp maybe_emit_sap_system_restored_event(
%SapSystem{instances: instances, health: health},
%RestoreSapSystem{sap_system_id: sap_system_id}
%RestoreSapSystem{sap_system_id: sap_system_id, db_host: db_host, tenant: tenant}
) do
if instances_have_abap?(instances) and instances_have_messageserver?(instances) do
%SapSystemRestored{
health: health,
db_host: db_host,
tenant: tenant,
sap_system_id: sap_system_id
}
end
Expand Down

0 comments on commit 3b74416

Please sign in to comment.