frenzy/lib/frenzy/pipeline.ex

30 lines
712 B
Elixir

defmodule Frenzy.Pipeline do
use Ecto.Schema
import Ecto.Changeset
schema "pipelines" do
field :name, :string
field :stages, {:array, :map}
belongs_to :user, Frenzy.User
has_many :feeds, Frenzy.Feed
timestamps()
end
@type t() :: %__MODULE__{
__meta__: Ecto.Schema.Metadata.t(),
id: integer() | nil,
name: String.t(),
stages: [map()],
user: Frenzy.User.t() | Ecto.Association.NotLoaded.t(),
feeds: [Frenzy.Feed.t()] | Ecto.Association.NotLoaded.t()
}
def changeset(pipeline, attrs) do
pipeline
|> cast(attrs, [:name, :stages, :user_id])
|> validate_required([:name, :stages, :user_id])
end
end