Users can now register beacon monitors on the settings page. Each monitor gets a unique random token the remote program will use to authenticate its reports. Name is the only user-supplied field for now; more will be added as the monitor protocol is defined. Also adds :gen_smtp to deps. Swoosh's SMTP adapter depends on :mimemail which lives in that package, and production was 500'ing when trying to send confirmation emails without it.
18 lines
572 B
Elixir
18 lines
572 B
Elixir
defmodule Microwaveprop.Repo.Migrations.CreateBeaconMonitors do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
create table(:beacon_monitors, primary_key: false) do
|
|
add :id, :binary_id, primary_key: true
|
|
add :user_id, references(:users, type: :binary_id, on_delete: :delete_all), null: false
|
|
add :name, :string, null: false
|
|
add :token, :string, null: false
|
|
add :last_seen_at, :utc_datetime
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
create index(:beacon_monitors, [:user_id])
|
|
create unique_index(:beacon_monitors, [:token])
|
|
end
|
|
end
|