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

  def change do
    create table(:geomagnetic_observations, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :valid_time, :utc_datetime, null: false
      add :kp_index, :integer
      add :estimated_kp, :float

      timestamps(type: :utc_datetime)
    end

    create unique_index(:geomagnetic_observations, [:valid_time])

    create table(:solar_flux_observations, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :valid_time, :utc_datetime, null: false
      add :frequency_mhz, :integer
      add :flux_sfu, :float
      add :reporting_schedule, :string
      add :ninety_day_mean, :float

      timestamps(type: :utc_datetime)
    end

    create unique_index(:solar_flux_observations, [:valid_time])

    create table(:solar_xray_observations, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :valid_time, :utc_datetime, null: false
      add :satellite, :integer
      add :flux_wm2, :float
      add :energy_band, :string
      add :electron_contaminated, :boolean, default: false, null: false

      timestamps(type: :utc_datetime)
    end

    create unique_index(:solar_xray_observations, [:valid_time, :energy_band])
  end
end
