# `Lightning.Workflows.Workflow`
[🔗](https://github.com/OpenFn/lightning/blob/main/lib/lightning/workflows/workflow.ex#L1)

Ecto model for Workflows.

A Workflow contains the fields for defining a workflow.

* `name`
  A plain text identifier. Any codepoint except a control character, see
  `Lightning.Validators.validate_name/3`, and at most 255 of them, which is
  the width of the column. The cap is higher than a job's 100 because
  workflow names predate any rule on the field, and nothing longer than the
  column width can already be stored.

# `t`

```elixir
@type t() :: %Lightning.Workflows.Workflow{
  __meta__: Ecto.Schema.Metadata.t(),
  concurrency: term(),
  delete: term(),
  deleted_at: term(),
  edges: term(),
  enable_job_logs: term(),
  id: Ecto.UUID.t() | nil,
  inserted_at: term(),
  jobs: term(),
  lock_version: term(),
  name: String.t() | nil,
  positions: term(),
  project:
    nil | Lightning.Projects.Project.t() | Ecto.Association.NotLoaded.t(),
  project_id: term(),
  runs: term(),
  snapshots: term(),
  state: term(),
  triggers: term(),
  updated_at: term(),
  versions: term(),
  work_orders: term()
}
```

# `json_fields`

```elixir
@spec json_fields() :: [atom()]
```

The fields this schema encodes to JSON.

Exposed so a caller can render a subset without restating the list and letting
the two drift apart. The REST API uses it to leave `:state` out, which names a
lifecycle we have not shipped.

# `request_deletion_changeset`

# `touch`

```elixir
@spec touch(t()) :: Ecto.Changeset.t(t())
```

Forces an update to the workflows `updated_at` timestamp and the
`lock_version`. This is useful when updating a child record like jobs or
triggers and a snapshot needs to made; but the Workflow itself didn't change.

# `validate`

# `workflow_activated?`

```elixir
@spec workflow_activated?(Ecto.Changeset.t()) :: boolean()
```

Returns true if the workflow has any triggers that are _going to be_ activated.

New triggers are enabled by default, but existing triggers are only considered
activated if their `enabled` field is _changed_ to `true`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
