defmodule ArcadiaCloud.Billing.CloudBalanceSnapshot do use Ecto.Schema import Ecto.Changeset @primary_key {:id, :binary_id, autogenerate: true} @foreign_key_type :binary_id schema "cloud_balance_snapshots" do field :provider, :string field :month_to_date_balance_cents, :integer field :account_balance_cents, :integer field :month_to_date_usage_cents, :integer field :generated_at, :utc_datetime field :raw, :map timestamps(type: :utc_datetime, updated_at: false) end @required ~w(provider generated_at)a @optional ~w(month_to_date_balance_cents account_balance_cents month_to_date_usage_cents raw)a def changeset(snap, attrs) do snap |> cast(attrs, @required ++ @optional) |> validate_required(@required) end end