defmodule Microwaveprop.Repo.Migrations.CreateQrzCallsignsAndCallsignLocations do
  use Ecto.Migration

  def change do
    create table(:qrz_callsigns, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :callsign, :string, null: false
      add :data, :map, null: false, default: %{}
      timestamps(type: :utc_datetime)
    end

    create unique_index(:qrz_callsigns, [:callsign])

    create table(:callsign_locations, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :callsign, :string, null: false
      add :latitude, :float, null: false
      add :longitude, :float, null: false
      add :gridsquare, :string, null: false
      timestamps(type: :utc_datetime)
    end

    create unique_index(:callsign_locations, [:callsign])
  end
end
