defmodule Cake.Layers.Template do
  use Ecto.Schema
  import Ecto.Changeset

  schema "layer_templates" do
    field :definition, :map
    field :id, Ecto.UUID
    field :name, :string
    field :version, :integer
    field :role, :id

    timestamps()
  end

  @doc false
  def changeset(template, attrs) do
    template
    |> cast(attrs, [:id, :name, :version, :definition])
    |> validate_required([:id, :name, :version, :definition])
  end
end