prop/priv/repo/migrations/20260408165341_create_beacons.exs
Graham McIntire ee9275e0b9 Add /beacons CRUD and /users admin page
Beacons:
- Scaffolded with phx.gen.live then reworked so reads are public
  and mutations go through a live_session gated by the new
  :require_admin on_mount hook in UserAuth
- Beacon schema stores frequency (MHz), callsign, grid, lat/lon,
  power (W), and height above ground (m); grid auto-derives from
  lat/lon when left blank via Maidenhead.from_latlon
- Adds Maidenhead.from_latlon/3 so we can compute grids locally
  instead of hitting an external API

Users admin page:
- /users and /users/:id/edit (admin-only) for listing, editing
  (callsign/name/email/is_admin), and deleting other users
- Adds Accounts.list_users, admin_update_user, delete_user, and
  a dedicated admin_changeset on the User schema
- Nav gains a "Users" link for admins and a "Beacons" link for
  everyone
2026-04-08 12:01:45 -05:00

21 lines
560 B
Elixir

defmodule Microwaveprop.Repo.Migrations.CreateBeacons do
use Ecto.Migration
def change do
create table(:beacons, primary_key: false) do
add :id, :binary_id, primary_key: true
add :frequency_mhz, :float
add :callsign, :string
add :grid, :string
add :lat, :float
add :lon, :float
add :power_watts, :float
add :height_m, :float
add :user_id, references(:users, type: :binary_id, on_delete: :delete_all)
timestamps(type: :utc_datetime)
end
create index(:beacons, [:user_id])
end
end