Phoenix 1.8 app that scrapes ammunition retailers (Lucky Gunner, SGAmmo) for price data and displays historical price trends. - Data model: retailers, calibers, products, price snapshots - Scraper infrastructure with Req, Floki, realistic browser headers - Oban-scheduled scrape jobs (every 4h with randomized delays) - LiveView pages: homepage with category cards, caliber detail with price table, Chart.js price history, and price stats banner - 18 seeded calibers across handgun/rifle/rimfire/shotgun categories - 77 tests
18 lines
511 B
Elixir
18 lines
511 B
Elixir
defmodule Ammoprices.Repo.Migrations.CreateRetailers do
|
|
use Ecto.Migration
|
|
|
|
def change do
|
|
create table(:retailers, primary_key: false) do
|
|
add :id, :binary_id, primary_key: true
|
|
add :name, :string, null: false
|
|
add :slug, :string, null: false
|
|
add :base_url, :string, null: false
|
|
add :enabled, :boolean, default: true, null: false
|
|
add :last_scraped_at, :utc_datetime
|
|
|
|
timestamps(type: :utc_datetime)
|
|
end
|
|
|
|
create unique_index(:retailers, [:slug])
|
|
end
|
|
end
|