-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create appup transform to set post_purge to soft
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
defmodule Archethic.Release.TransformPurge do | ||
use Distillery.Releases.Appup.Transform | ||
|
||
@default_change {:advanced, []} | ||
|
||
def up(:archethic, _v1, _v2, instructions, _opts), do: transform(instructions, []) | ||
|
||
def up(_, _, _, instructions, _), do: instructions | ||
|
||
def down(:archethic, _v1, _v2, instructions, _opts), do: transform(instructions, []) | ||
|
||
def down(_, _, _, instructions, _), do: instructions | ||
|
||
defp transform([], acc), do: Enum.reverse(acc) | ||
|
||
defp transform([instruction | rest], acc) do | ||
call = elem(instruction, 0) | ||
|
||
new_instruction = | ||
case call do | ||
:update -> | ||
handle_update(instruction) | ||
|
||
call when call in [:load, :load_module] -> | ||
handle_load(instruction) | ||
|
||
_ -> | ||
instruction | ||
end | ||
|
||
transform(rest, [new_instruction | acc]) | ||
end | ||
|
||
defp handle_update(instruction = {_call, _module, :supervisor}), do: instruction | ||
|
||
defp handle_update({call, module}), | ||
do: {call, module, @default_change, :brutal_purge, :soft_purge} | ||
|
||
defp handle_update({call, module, change}) when is_tuple(change), | ||
do: {call, module, change, :brutal_purge, :soft_purge} | ||
|
||
defp handle_update({call, module, deps}) when is_list(deps), | ||
do: {call, module, @default_change, :brutal_purge, :soft_purge, deps} | ||
|
||
defp handle_update({call, module, change, deps}), | ||
do: {call, module, change, :brutal_purge, :soft_purge, deps} | ||
|
||
# Other change already contain purge so we don't overwrite them | ||
defp handle_update(instruction), do: instruction | ||
|
||
defp handle_load({call, module}), do: {call, module, :brutal_purge, :soft_purge, []} | ||
|
||
defp handle_load({call, module, deps}), | ||
do: {call, module, :brutal_purge, :soft_purge, deps} | ||
|
||
# Other change already contain purge so we don't overwrite them | ||
defp handle_load(instruction), do: instruction | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters