From 4062b4d0ac879c2667ef32c3048f1db890e77f6f Mon Sep 17 00:00:00 2001 From: Neylix Date: Tue, 8 Oct 2024 12:13:21 +0200 Subject: [PATCH] Use Version module on migrate version compare --- lib/mix/tasks/migrate.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/mix/tasks/migrate.ex b/lib/mix/tasks/migrate.ex index 91de7f903..c46a6afb6 100644 --- a/lib/mix/tasks/migrate.ex +++ b/lib/mix/tasks/migrate.ex @@ -65,7 +65,9 @@ defmodule Mix.Tasks.Archethic.Migrate do migration_version = Regex.run(~r/.*(?=@)/, file_name) |> List.first() {migration_version, migration_path} end) - |> Enum.filter(fn {migration_version, _} -> last_version < migration_version end) + |> Enum.filter(fn {migration_version, _} -> + Version.compare(last_version, migration_version) == :lt + end) |> Enum.map(fn {version, path} -> {version, Code.eval_file(path)} end) |> Enum.filter(fn {_version, {{:module, module, _, _}, _}} -> @@ -80,6 +82,7 @@ defmodule Mix.Tasks.Archethic.Migrate do false end) |> Enum.map(fn {version, {{_, module, _, _}, _}} -> {version, module} end) + |> Enum.sort_by(&elem(&1, 0), Version) end defp get_migrations_path() do