From 2de59138e4f275441978c3cbbda359f6168e080c Mon Sep 17 00:00:00 2001 From: Ben Hale Date: Thu, 12 Mar 2026 19:45:26 -0700 Subject: [PATCH] fix: restore earthdistance function search paths Reapply the public search_path for ll_to_earth and earth_box after the earthdistance extension upgrade. TeslaMate previously set these functions to use the public schema to avoid lookup errors around the earth type. The later earthdistance update migration upgrades the extension but does not restore that custom function metadata, which can leave the functions without the expected search path. This adds a follow-up migration that sets the search path for both functions back to public and updates restore documentation to include these changes. Signed-off-by: Ben Hale --- nix/backup_and_restore.nix | 2 ++ ...0_set_search_path_for_earthdistance_functions.exs | 12 ++++++++++++ website/docs/installation/unsupported/unraid.md | 2 ++ website/docs/maintenance/backup_restore.mdx | 2 ++ 4 files changed, 18 insertions(+) create mode 100644 priv/repo/migrations/20260502120000_set_search_path_for_earthdistance_functions.exs diff --git a/nix/backup_and_restore.nix b/nix/backup_and_restore.nix index 1a30f4bcd5..ee38456a3a 100644 --- a/nix/backup_and_restore.nix +++ b/nix/backup_and_restore.nix @@ -25,6 +25,8 @@ let create schema public; CREATE EXTENSION cube WITH SCHEMA public; CREATE EXTENSION earthdistance WITH SCHEMA public; + ALTER FUNCTION ll_to_earth SET search_path = public; + ALTER FUNCTION earth_box SET search_path = public; . # Restore diff --git a/priv/repo/migrations/20260502120000_set_search_path_for_earthdistance_functions.exs b/priv/repo/migrations/20260502120000_set_search_path_for_earthdistance_functions.exs new file mode 100644 index 0000000000..7b5dca548a --- /dev/null +++ b/priv/repo/migrations/20260502120000_set_search_path_for_earthdistance_functions.exs @@ -0,0 +1,12 @@ +defmodule TeslaMate.Repo.Migrations.SetSearchPathForEarthdistanceFunctions do + use Ecto.Migration + + def up do + execute("ALTER FUNCTION ll_to_earth SET search_path = public") + execute("ALTER FUNCTION earth_box SET search_path = public") + end + + def down do + :ok + end +end diff --git a/website/docs/installation/unsupported/unraid.md b/website/docs/installation/unsupported/unraid.md index beaf9c57dc..24e7ae4f6e 100644 --- a/website/docs/installation/unsupported/unraid.md +++ b/website/docs/installation/unsupported/unraid.md @@ -187,6 +187,8 @@ DROP SCHEMA private 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; +ALTER FUNCTION earth_box SET search_path = public; SQL if [ $? -ne 0 ]; then diff --git a/website/docs/maintenance/backup_restore.mdx b/website/docs/maintenance/backup_restore.mdx index 3c909b6563..089a4598a5 100644 --- a/website/docs/maintenance/backup_restore.mdx +++ b/website/docs/maintenance/backup_restore.mdx @@ -80,6 +80,8 @@ DROP SCHEMA private 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; +ALTER FUNCTION earth_box SET search_path = public; . # Restore