2022-08-06 07:27:22 +12:00
|
|
|
defmodule AshPostgres.TestRepo.Migrations.Install4Extensions do
|
2022-07-21 06:19:06 +12:00
|
|
|
@moduledoc """
|
|
|
|
Installs any extensions that are mentioned in the repo's `installed_extensions/0` callback
|
|
|
|
|
|
|
|
This file was autogenerated with `mix ash_postgres.generate_migrations`
|
|
|
|
"""
|
|
|
|
|
|
|
|
use Ecto.Migration
|
|
|
|
|
|
|
|
def up do
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_or(left BOOLEAN, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE)
|
|
|
|
AS $$ SELECT COALESCE(NULLIF($1, FALSE), $2) $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
|
|
|
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_or(left ANYCOMPATIBLE, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE)
|
|
|
|
AS $$ SELECT COALESCE($1, $2) $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
|
|
|
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_and(left BOOLEAN, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE) AS $$
|
|
|
|
SELECT CASE
|
|
|
|
WHEN $1 IS TRUE THEN $2
|
|
|
|
ELSE $1
|
|
|
|
END $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
|
|
|
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_and(left ANYCOMPATIBLE, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE) AS $$
|
|
|
|
SELECT CASE
|
|
|
|
WHEN $1 IS NOT NULL THEN $2
|
|
|
|
ELSE $1
|
|
|
|
END $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
2022-08-06 07:27:22 +12:00
|
|
|
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_or(left BOOLEAN, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE)
|
|
|
|
AS $$ SELECT COALESCE(NULLIF($1, FALSE), $2) $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
|
|
|
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_or(left ANYCOMPATIBLE, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE)
|
|
|
|
AS $$ SELECT COALESCE($1, $2) $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
|
|
|
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_and(left BOOLEAN, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE) AS $$
|
|
|
|
SELECT CASE
|
|
|
|
WHEN $1 IS TRUE THEN $2
|
|
|
|
ELSE $1
|
|
|
|
END $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
|
|
|
|
|
|
|
execute("""
|
|
|
|
CREATE OR REPLACE FUNCTION ash_elixir_and(left ANYCOMPATIBLE, in right ANYCOMPATIBLE, out f1 ANYCOMPATIBLE) AS $$
|
|
|
|
SELECT CASE
|
|
|
|
WHEN $1 IS NOT NULL THEN $2
|
|
|
|
ELSE $1
|
|
|
|
END $$
|
|
|
|
LANGUAGE SQL;
|
|
|
|
""")
|
|
|
|
|
|
|
|
execute("CREATE EXTENSION IF NOT EXISTS \"uuid-ossp\"")
|
|
|
|
execute("CREATE EXTENSION IF NOT EXISTS \"pg_trgm\"")
|
|
|
|
execute("CREATE EXTENSION IF NOT EXISTS \"citext\"")
|
2022-07-21 06:19:06 +12:00
|
|
|
end
|
|
|
|
|
|
|
|
def down do
|
|
|
|
# Uncomment this if you actually want to uninstall the extensions
|
|
|
|
# when this migration is rolled back:
|
|
|
|
execute(
|
|
|
|
"DROP FUNCTION IF EXISTS ash_elixir_and(BOOLEAN, ANYCOMPATIBLE), ash_elixir_and(ANYCOMPATIBLE, ANYCOMPATIBLE), ash_elixir_or(ANYCOMPATIBLE, ANYCOMPATIBLE), ash_elixir_or(BOOLEAN, ANYCOMPATIBLE)"
|
|
|
|
)
|
2022-08-06 07:27:22 +12:00
|
|
|
|
|
|
|
# execute("DROP EXTENSION IF EXISTS \"uuid-ossp\"")
|
|
|
|
# execute("DROP EXTENSION IF EXISTS \"pg_trgm\"")
|
|
|
|
# execute("DROP EXTENSION IF EXISTS \"citext\"")
|
2022-07-21 06:19:06 +12:00
|
|
|
end
|
|
|
|
end
|