mirror of
https://github.com/ash-project/ash_postgres.git
synced 2024-09-20 13:33:50 +12:00
eb2bd267cb
chore: rebuild test migrations
87 lines
No EOL
2.7 KiB
Elixir
87 lines
No EOL
2.7 KiB
Elixir
defmodule AshPostgres.TestRepo.Migrations.Install4Extensions do
|
|
@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;
|
|
""")
|
|
|
|
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\"")
|
|
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)"
|
|
)
|
|
|
|
# execute("DROP EXTENSION IF EXISTS \"uuid-ossp\"")
|
|
# execute("DROP EXTENSION IF EXISTS \"pg_trgm\"")
|
|
# execute("DROP EXTENSION IF EXISTS \"citext\"")
|
|
end
|
|
end |