ash_sqlite/test/support/test_custom_extension.ex

39 lines
712 B
Elixir
Raw Normal View History

2023-09-23 14:52:22 +12:00
defmodule AshSqlite.TestCustomExtension do
@moduledoc false
use AshSqlite.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