Lightning.Workflows.Workflow (Lightning v2.20.0)

Copy Markdown View Source

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.

Summary

Functions

The fields this schema encodes to JSON.

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.

Returns true if the workflow has any triggers that are going to be activated.

Types

t()

@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()
}

Functions

json_fields()

@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(workflow, attrs)

touch(workflow)

@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(changeset)

workflow_activated?(changeset)

@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.