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

  def change do
    create table(:metar_5min_observations, primary_key: false) do
      add :id, :binary_id, primary_key: true, null: false
      add :station_id, references(:weather_stations, type: :binary_id, on_delete: :delete_all)
      add :observed_at, :utc_datetime, null: false
      add :temp_f, :float
      add :dewpoint_f, :float
      add :relative_humidity, :float
      add :wind_speed_kts, :float
      add :wind_direction_deg, :integer
      add :sea_level_pressure_mb, :float
      add :altimeter_setting, :float
      add :sky_condition, :string
      add :precip_1h_in, :float
      add :wx_codes, :string

      timestamps(type: :utc_datetime)
    end

    create unique_index(:metar_5min_observations, [:station_id, :observed_at])
    create index(:metar_5min_observations, [:observed_at])
  end
end
