> ## Documentation Index
> Fetch the complete documentation index at: https://docs.serial.okos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Process Entries

> An in-depth look at the structure and purpose of the `process_steps` table in the Serial database

## Introduction to the PROCESS\_STEPS Table

The process\_steps table is designed to store detailed information about individual steps within a process. This table plays a crucial role in organizing and structuring the workflow of manufacturing processes in the Serial system.

## Table Structure

The process\_steps table is structured to capture essential data about each step in a process. Here's a detailed breakdown of its columns:

| Column Name            | Data Type | Constraints             | Description                                      |
| ---------------------- | --------- | ----------------------- | ------------------------------------------------ |
| id                     | uuid      | primary key             | Unique identifier for each process step          |
| company\_id            | uuid      | not null, foreign key   | Reference to the company owning the process step |
| order                  | int       | not null                | Sequence number of the step within the process   |
| name                   | text      | not null                | Name or description of the process step          |
| process\_id            | uuid      | not null, foreign key   | Reference to the associated process              |
| process\_revision      | int       | not null                | Revision number of the associated process        |
| filter\_join\_operator | text      | not null                | Operator for joining filter conditions           |
| created\_at            | timestamp | not null, default now() | Timestamp of when the step was created           |
| is\_hidden             | boolean   | not null, default false | Flag to indicate if the step is hidden           |

## Usage and Functionality

The process\_steps table is designed to be a flexible and integral part of the process management system. Here are some key points about its usage:

1. **Process Organization**: Each row in the table represents a distinct step within a process, allowing for detailed structuring of complex workflows.

2. **Versioning Support**: The inclusion of both process\_id and process\_revision allows for maintaining multiple versions of process steps, supporting iterative improvements and change management.

3. **Filtering and Conditional Logic**: The filter\_join\_operator column suggests that steps can have associated conditions, potentially allowing for dynamic workflow adjustments based on specific criteria.

4. **Company-Specific Processes**: The company\_id foreign key ensures that process steps are associated with specific companies, enabling multi-tenant support in the system.

## Notes

* The table includes indexes on company\_id and process\_id, optimizing queries that filter or join on these columns.

* The table is utilized in functions like `insert_process_with_references` and `get_process_with_references`, indicating its central role in process management operations.

* Example usage in a function:

  ```sql
  INSERT INTO public.process_steps (company_id, "order", name, process_id, process_revision, filter_join_operator, is_hidden)
  VALUES (
      (process_step_json->>'company_id')::UUID,
      (process_step_json->>'order')::INTEGER,
      process_step_json->>'name',
      process_id,
      process_revision,
      process_step_json->>'filter_join_operator',
      COALESCE(process_step_json->>'is_hidden', 'false')::BOOLEAN
  )
  ```

* The is\_hidden column allows for temporarily removing steps from view without deleting them, providing flexibility in process management.

By leveraging the process\_steps table, the Serial application can maintain a detailed and versioned representation of manufacturing processes, enabling complex workflow management and supporting the core functionality of the system.
