Skip to content

Commit

Permalink
fix: properly pass old version in when migrating extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed May 5, 2024
1 parent 4dd588c commit 3334999
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/migration_generator/migration_generator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,18 @@ defmodule AshPostgres.MigrationGenerator do
extensions_snapshot[:ash_functions_version]
)

{_ext_name, version, up_fn, _down_fn} when is_function(up_fn, 1) ->
up_fn.(version)
{ext_name, _version, up_fn, _down_fn} when is_function(up_fn, 1) ->
current_version =
Enum.find_value(extensions_snapshot[:installed] || [], 0, fn name ->
with ["", "v" <> version] <- String.split(name, to_string(ext_name)),
{integer, ""} <- Integer.parse(version) do
integer
else
_ -> nil
end
end)

up_fn.(current_version)

extension ->
"execute(\"CREATE EXTENSION IF NOT EXISTS \\\"#{extension}\\\"\")"
Expand Down

0 comments on commit 3334999

Please sign in to comment.