Skip to content

Commit

Permalink
Handle old migration format
Browse files Browse the repository at this point in the history
  • Loading branch information
Neylix committed Mar 23, 2023
1 parent 4887388 commit c1d3052
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/mix/tasks/migrate.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule Mix.Tasks.Archethic.Migrate do

migrations_to_run =
if File.exists?(migration_file_path) do
File.read!(migration_file_path) |> filter_migrations_to_run(function)
read_file(migration_file_path) |> filter_migrations_to_run(function)
else
# File does not exist when it's the first time the node is started
# We create the folder to write the migration file on first start
Expand Down Expand Up @@ -99,4 +99,17 @@ defmodule Mix.Tasks.Archethic.Migrate do
:code.delete(module)
:code.purge(module)
end

defp read_file(path) do
# handle old migration file format
file_content = File.read!(path)

if String.contains?(file_content, ";") do
last_version = file_content |> String.split(";") |> Enum.reject(&(&1 == "")) |> List.last()
File.write(path, last_version)
last_version
else
file_content
end
end
end

0 comments on commit c1d3052

Please sign in to comment.