ash_postgres/lib/custom_extension.ex
Alessio Montagnani 4a02d8c6ad
improvement: custom-extension implementation (#162)
* improvement: custom-extension implementation

* improvement: allow adding custom-extension by module's reference and fixes formatting

* ci: fixes formatter
2023-08-08 10:20:26 -07:00

20 lines
548 B
Elixir

defmodule AshPostgres.CustomExtension do
@moduledoc """
A custom extension implementation.
"""
@callback install(version :: integer) :: String.t()
@callback uninstall(version :: integer) :: String.t()
defmacro __using__(name: name, latest_version: latest_version) do
quote do
@behaviour AshPostgres.CustomExtension
@extension_name unquote(name)
@extension_latest_version unquote(latest_version)
def extension, do: {@extension_name, @extension_latest_version, &install/1, &uninstall/1}
end
end
end