From 3a710a71938dd001065d61a5a0a74b726a89cd22 Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sun, 29 Sep 2024 08:31:45 +0200 Subject: [PATCH] try specifying public schema for extensions --- .../20190925152807_create_geo_extensions.exs | 10 ++++++++-- website/docs/maintenance/backup_restore.md | 15 +++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/priv/repo/migrations/20190925152807_create_geo_extensions.exs b/priv/repo/migrations/20190925152807_create_geo_extensions.exs index 229e5d7f426..4ed3edfc52f 100644 --- a/priv/repo/migrations/20190925152807_create_geo_extensions.exs +++ b/priv/repo/migrations/20190925152807_create_geo_extensions.exs @@ -2,8 +2,14 @@ defmodule TeslaMate.Repo.Migrations.CreateGeoExtensions do use Ecto.Migration def change do - execute("CREATE EXTENSION IF NOT EXISTS cube", "DROP EXTENSION cube") - execute("CREATE EXTENSION IF NOT EXISTS earthdistance", "DROP EXTENSION earthdistance") + execute("CREATE EXTENSION IF NOT EXISTS cube WITH SCHEMA public", "DROP EXTENSION cube") + + execute( + "CREATE EXTENSION IF NOT EXISTS earthdistance WITH SCHEMA public", + "DROP EXTENSION earthdistance" + ) + + execute("ALTER FUNCTION ll_to_earth SET search_path = public") create(index(:geofences, ["(earth_box(ll_to_earth(latitude, longitude), radius))"])) end end diff --git a/website/docs/maintenance/backup_restore.md b/website/docs/maintenance/backup_restore.md index f84899c87d2..6ffa84c8c61 100644 --- a/website/docs/maintenance/backup_restore.md +++ b/website/docs/maintenance/backup_restore.md @@ -41,16 +41,11 @@ docker compose stop teslamate # Drop existing data and reinitialize (Don't forget to replace first teslamate if using different TM_DB_USER) docker compose exec -T database psql -U teslamate teslamate << . -drop schema public cascade; -create schema public; -create extension cube; -create extension earthdistance; -CREATE OR REPLACE FUNCTION public.ll_to_earth(float8, float8) - RETURNS public.earth - LANGUAGE SQL - IMMUTABLE STRICT - PARALLEL SAFE - AS 'SELECT public.cube(public.cube(public.cube(public.earth()*cos(radians(\$1))*cos(radians(\$2))),public.earth()*cos(radians(\$1))*sin(radians(\$2))),public.earth()*sin(radians(\$1)))::public.earth'; +DROP SCHEMA public CASCADE; +CREATE SCHEMA public; +CREATE EXTENSION cube WITH SCHEMA public; +CREATE EXTENSION earthdistance WITH SCHEMA public; +ALTER FUNCTION ll_to_earth SET search_path = public; . # Restore