From 16fe7aa9203823ed0f5f49907699d3ad82d2cf8d Mon Sep 17 00:00:00 2001 From: Matthias Wirtz Date: Sun, 29 Sep 2024 08:50:24 +0200 Subject: [PATCH] PostgreSQL 17 --- .github/workflows/elixir.yml | 2 +- .../20190925152807_create_geo_extensions.exs | 11 +++++++++-- .../20240929084639_recreate_geo_extensions.exs | 9 +++++++++ website/docs/development.md | 2 +- website/docs/guides/apache.md | 2 +- website/docs/guides/traefik.md | 2 +- website/docs/installation/debian.md | 17 ++++------------- website/docs/installation/docker.md | 2 +- website/docs/installation/freebsd.md | 10 +++++----- website/docs/maintenance/backup_restore.md | 14 ++++---------- 10 files changed, 36 insertions(+), 35 deletions(-) create mode 100644 priv/repo/migrations/20240929084639_recreate_geo_extensions.exs diff --git a/.github/workflows/elixir.yml b/.github/workflows/elixir.yml index 4bf53c7880..6cbed2a3e7 100644 --- a/.github/workflows/elixir.yml +++ b/.github/workflows/elixir.yml @@ -129,7 +129,7 @@ jobs: services: db: - image: postgres:16 + image: postgres:17 ports: ["5432:5432"] env: POSTGRES_PASSWORD: postgres diff --git a/priv/repo/migrations/20190925152807_create_geo_extensions.exs b/priv/repo/migrations/20190925152807_create_geo_extensions.exs index 229e5d7f42..6eb853c94a 100644 --- a/priv/repo/migrations/20190925152807_create_geo_extensions.exs +++ b/priv/repo/migrations/20190925152807_create_geo_extensions.exs @@ -2,8 +2,15 @@ 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") + execute("ALTER FUNCTION earth_box SET search_path = public") create(index(:geofences, ["(earth_box(ll_to_earth(latitude, longitude), radius))"])) end end diff --git a/priv/repo/migrations/20240929084639_recreate_geo_extensions.exs b/priv/repo/migrations/20240929084639_recreate_geo_extensions.exs new file mode 100644 index 0000000000..a303a10eb5 --- /dev/null +++ b/priv/repo/migrations/20240929084639_recreate_geo_extensions.exs @@ -0,0 +1,9 @@ +defmodule TeslaMate.Repo.Migrations.RecreateGeoExtensions do + use Ecto.Migration + + def change do + execute("DROP EXTENSION cube CASCADE") + execute("CREATE EXTENSION cube WITH SCHEMA public") + execute("CREATE EXTENSION earthdistance WITH SCHEMA public") + end +end diff --git a/website/docs/development.md b/website/docs/development.md index 631775f809..f937fd77be 100644 --- a/website/docs/development.md +++ b/website/docs/development.md @@ -7,7 +7,7 @@ sidebar_label: Development and Contributing ## Requirements - **Elixir** >= 1.16.2-otp-26 -- **Postgres** >= 16 +- **Postgres** >= 17 - An **MQTT broker** e.g. mosquitto (_optional_) - **NodeJS** >= 20.15.0 diff --git a/website/docs/guides/apache.md b/website/docs/guides/apache.md index 19e4bad871..cb7848697d 100644 --- a/website/docs/guides/apache.md +++ b/website/docs/guides/apache.md @@ -50,7 +50,7 @@ services: - all database: - image: postgres:16 + image: postgres:17 restart: always environment: - POSTGRES_USER=${TM_DB_USER} diff --git a/website/docs/guides/traefik.md b/website/docs/guides/traefik.md index 31a8ef4eca..1350510f22 100644 --- a/website/docs/guides/traefik.md +++ b/website/docs/guides/traefik.md @@ -60,7 +60,7 @@ services: - ALL database: - image: postgres:16 + image: postgres:17 restart: always environment: - POSTGRES_USER=${TM_DB_USER} diff --git a/website/docs/installation/debian.md b/website/docs/installation/debian.md index d1677d0d40..9dc6657361 100644 --- a/website/docs/installation/debian.md +++ b/website/docs/installation/debian.md @@ -10,13 +10,13 @@ This document provides the necessary steps for installation of TeslaMate on a va Click on the following items to view detailed installation steps.
- Postgres (v12+) + Postgres (v17+) ```bash wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - -echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list +echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list sudo apt-get update -sudo apt-get install -y postgresql-12 postgresql-client-12 +sudo apt-get install -y postgresql-17 postgresql-client-17 ``` Source: [postgresql.org/download](https://www.postgresql.org/download/) @@ -37,7 +37,7 @@ Source: [elixir-lang.org/install](https://elixir-lang.org/install)
- Grafana (v8.3.4+) & Plugins + Grafana (v11.1.0+) ```bash sudo apt-get install -y apt-transport-https software-properties-common @@ -51,15 +51,6 @@ sudo systemctl enable grafana-server.service # to start Grafana at boot time Source: [grafana.com/docs/installation](https://grafana.com/docs/grafana/latest/installation/) -Install the required Grafana plugins as well: - -```bash -sudo grafana-cli plugins install pr0ps-trackmap-panel 2.1.4 -sudo grafana-cli plugins install natel-plotly-panel 0.0.7 -sudo grafana-cli --pluginUrl https://github.com/panodata/panodata-map-panel/releases/download/0.16.0/panodata-map-panel-0.16.0.zip plugins install grafana-worldmap-panel-ng -sudo systemctl restart grafana-server -``` - [Import the Grafana dashboards](#import-grafana-dashboards) after [cloning the TeslaMate git repository](#clone-teslamate-git-repository).
diff --git a/website/docs/installation/docker.md b/website/docs/installation/docker.md index fabf187926..6f1e82daf4 100644 --- a/website/docs/installation/docker.md +++ b/website/docs/installation/docker.md @@ -38,7 +38,7 @@ This setup is recommended only if you are running TeslaMate **on your home netwo - all database: - image: postgres:16 + image: postgres:17 restart: always environment: - POSTGRES_USER=teslamate diff --git a/website/docs/installation/freebsd.md b/website/docs/installation/freebsd.md index 78bd5e2bdc..1a72d65113 100644 --- a/website/docs/installation/freebsd.md +++ b/website/docs/installation/freebsd.md @@ -50,11 +50,11 @@ pkg install elixir
- Postgres (v14+) + Postgres (v17+) ```bash -pkg install postgresql16-server-16.0 -pkg install postgresql16-contrib-16.0 +pkg install postgresql17-server-17.0 +pkg install postgresql17-contrib-17.0 echo postgres_enable="yes" >> /etc/rc.conf ``` @@ -70,12 +70,12 @@ service postgresql initdb
- Grafana (v8.3.4+) & Plugins + Grafana (v10.4.5+) (might be obsolete with Grafana 9, I had no issues with a fresh install) The latest Grafana from ports/pkg has a startup issue with the rc script, starting via rc.local is the workaround. ```bash -pkg install grafana9-9.5.7_2 +pkg install grafana-10.4.5_1 echo grafana_enable="yes" >> /etc/rc.conf # Only needed if grafana fails to start via rc.conf echo "cd /tmp && /usr/local/etc/rc.d/grafana onestart" >> /etc/rc.local diff --git a/website/docs/maintenance/backup_restore.md b/website/docs/maintenance/backup_restore.md index f84899c87d..e70bc86fdc 100644 --- a/website/docs/maintenance/backup_restore.md +++ b/website/docs/maintenance/backup_restore.md @@ -41,16 +41,10 @@ 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; . # Restore