ash_postgres/test/support/test_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

38 lines
716 B
Elixir

defmodule AshPostgres.TestCustomExtension do
@moduledoc false
use AshPostgres.CustomExtension, name: "demo-functions", latest_version: 1
@impl true
def install(0) do
"""
execute(\"\"\"
CREATE OR REPLACE FUNCTION ash_demo_functions()
RETURNS boolean AS $$ SELECT TRUE $$
LANGUAGE SQL
IMMUTABLE;
\"\"\")
"""
end
@impl true
def install(1) do
"""
execute(\"\"\"
CREATE OR REPLACE FUNCTION ash_demo_functions()
RETURNS boolean AS $$ SELECT FALSE $$
LANGUAGE SQL
IMMUTABLE;
\"\"\")
"""
end
@impl true
def uninstall(_version) do
"""
execute(\"\"\"
DROP FUNCTION IF EXISTS ash_demo_functions()
\"\"\")
"""
end
end