defmodule Prymn.Servers.Server do use Ecto.Schema import Ecto.Changeset schema "servers" do field :name, :string field :public_ip, :string field :provider, Ecto.Enum, values: [:Hetzner, :Custom] field :registration_token, :binary, redact: true field :connection_status, Ecto.Enum, values: [:awaiting, :connecting, :installing, :connected, :disconnected], default: :awaiting timestamps() end @doc false def changeset(server, attrs) do server |> cast(attrs, [:name, :provider, :registration_token]) |> validate_required([:name, :provider]) |> validate_inclusion(:provider, [:Custom], message: "Provider not available (yet)") end end