defmodule Ammoprices.Repo.Migrations.CreatePriceSnapshots do use Ecto.Migration def change do create table(:price_snapshots, primary_key: false) do add :id, :binary_id, primary_key: true add :product_id, references(:products, type: :binary_id, on_delete: :delete_all), null: false add :price_cents, :integer, null: false add :price_per_round_cents, :integer, null: false add :in_stock, :boolean, default: true, null: false add :recorded_at, :utc_datetime, null: false timestamps(type: :utc_datetime, updated_at: false) end create index(:price_snapshots, [:product_id, :recorded_at]) create index(:price_snapshots, [:recorded_at]) end end