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

  def change do
    create table(:gefs_profiles, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :valid_time, :utc_datetime, null: false
      add :lat, :float, null: false
      add :lon, :float, null: false
      add :run_time, :utc_datetime
      add :forecast_hour, :integer
      add :profile, {:array, :map}, default: []
      add :pwat_mm, :float
      add :surface_temp_c, :float
      add :surface_dewpoint_c, :float
      add :surface_pressure_mb, :float
      add :surface_refractivity, :float
      add :min_refractivity_gradient, :float
      add :ducting_detected, :boolean, default: false
      add :duct_characteristics, {:array, :map}
      add :wind_u_mps, :float
      add :wind_v_mps, :float
      add :cloud_cover_pct, :float
      add :precip_mm, :float

      timestamps(type: :utc_datetime)
    end

    create unique_index(:gefs_profiles, [:lat, :lon, :valid_time])
    create index(:gefs_profiles, [:valid_time])
    create index(:gefs_profiles, [:run_time])
  end
end
