prop/lib/microwaveprop/aprs_repo.ex
Graham McIntire 714d1ce432
feat(aprs): add read-only AprsRepo for aprs.me database access
Wire up Microwaveprop.AprsRepo as an optional secondary Ecto repo that
points at the sister aprs.me Postgres for read-only access. This is the
foundation for upcoming 144 MHz calibration work that uses verified APRS
RF hops as ground truth.

* lib/microwaveprop/aprs_repo.ex declares a read_only repo; no schemas,
  no migrations, no writes — Microwaveprop never persists APRS data.
* Application supervisor starts the repo only when configured (dev/test
  via config blocks, prod via APRS_DATABASE_URL). A missing config logs
  a warning and skips startup so the main app still boots.
* config/dev.exs + config/test.exs add local aprsme_dev / aprsme_test
  endpoints. Test pool uses Ecto SQL Sandbox; tests that don't touch
  APRS data don't need to check the connection out.
* config/runtime.exs guards the prod block on APRS_DATABASE_URL —
  unset env logs a warning and leaves the repo unconfigured.
2026-05-01 12:25:33 -05:00

17 lines
623 B
Elixir

defmodule Microwaveprop.AprsRepo do
@moduledoc """
Secondary repo for read-only access to aprs.me's `packets` table.
Used by `Microwaveprop.Aprs` and the `Mix.Tasks.Calibrate.Aprs144` mix
task to pull verified RF hops as ground truth for 144 MHz scoring.
This repo never owns schema, migrations, or writes — it only ever
issues SELECT queries against aprs.me's existing partitioned `packets`
table. The connection is configured to fail closed if `APRS_DATABASE_URL`
is unset in production.
"""
use Ecto.Repo,
otp_app: :microwaveprop,
adapter: Ecto.Adapters.Postgres,
read_only: true
end