Skip to content

Commit

Permalink
try specifying public schema for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
swiffer committed Sep 29, 2024
1 parent 01fc100 commit 3a710a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 8 additions & 2 deletions priv/repo/migrations/20190925152807_create_geo_extensions.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 5 additions & 10 deletions website/docs/maintenance/backup_restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3a710a7

Please sign in to comment.