Skip to content

Commit

Permalink
feat: PostgreSQL 17 (#4231)
Browse files Browse the repository at this point in the history
  • Loading branch information
swiffer authored Sep 29, 2024
1 parent 5737c54 commit c67573e
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:

services:
db:
image: postgres:16
image: postgres:17
ports: ["5432:5432"]
env:
POSTGRES_PASSWORD: postgres
Expand Down
11 changes: 9 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,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
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion website/docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/apache.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ services:
- all

database:
image: postgres:16
image: postgres:17
restart: always
environment:
- POSTGRES_USER=${TM_DB_USER}
Expand Down
2 changes: 1 addition & 1 deletion website/docs/guides/traefik.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ services:
- ALL

database:
image: postgres:16
image: postgres:17
restart: always
environment:
- POSTGRES_USER=${TM_DB_USER}
Expand Down
17 changes: 4 additions & 13 deletions website/docs/installation/debian.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>
<summary>Postgres (v12+)</summary>
<summary>Postgres (v17+)</summary>

```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/)
Expand All @@ -37,7 +37,7 @@ Source: [elixir-lang.org/install](https://elixir-lang.org/install)
</details>

<details>
<summary>Grafana (v8.3.4+) & Plugins</summary>
<summary>Grafana (v11.1.0+)</summary>

```bash
sudo apt-get install -y apt-transport-https software-properties-common
Expand All @@ -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).

</details>
Expand Down
2 changes: 1 addition & 1 deletion website/docs/installation/docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions website/docs/installation/freebsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ pkg install elixir
</details>

<details>
<summary>Postgres (v14+)</summary>
<summary>Postgres (v17+)</summary>

```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
```

Expand All @@ -70,12 +70,12 @@ service postgresql initdb
</details>

<details>
<summary>Grafana (v8.3.4+) & Plugins</summary>
<summary>Grafana (v10.4.5+)</summary>

(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
Expand Down
14 changes: 4 additions & 10 deletions website/docs/maintenance/backup_restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c67573e

Please sign in to comment.