Introduction to the Operators Table
The operators table is designed to track multiple operators within the Serial system without the need to create full user accounts for each one. This table plays a crucial role in managing operator information, particularly for Contract Manufacturers (CMs), allowing them to maintain operator records and PINs independently of the user authentication system.Table Structure
The operators table is structured to store essential information about each operator while maintaining flexibility and efficiency. Here’s a detailed breakdown of its columns:| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key, not null, default uuid_generate_v4() | Unique identifier for each operator |
| first_name | text | not null | Operator’s first name |
| last_name | text | Operator’s last name (optional) | |
| pin | text | Personal Identification Number for the operator (optional) | |
| user_id | text | foreign key (users.supabase_uid) | Reference to the associated user account, if any |
| created_at | timestamp with time zone | not null, default now() | Timestamp of when the operator record was created |
| company_id | uuid | not null, foreign key (companies.id) | Reference to the company the operator belongs to |
| is_active | boolean | not null, default true | Indicates whether the operator is currently active |
Usage and Functionality
The operators table is designed to be flexible and secure, accommodating various operator management needs. Here are some key points about its usage:- Unique Constraint: The table enforces a unique constraint on the combination of (first_name, last_name, pin, company_id), ensuring that no duplicate operator records exist within the same company.
- Process Entry Association: Operators are linked to process entries, allowing for tracking of which operator performed specific actions or processes within the system.
-
Active Status Management: The
is_activecolumn allows for easy management of operator status, enabling temporary deactivation without deleting the record.
Notes
- The table supports PIN management for operators, allowing CMs to maintain operator PINs without needing to create full user accounts in the organization.
-
Validation functions are implemented to ensure data integrity, such as checking PIN availability and non-emptiness:
- The OperatorTable component in the frontend provides a user interface for managing operators, including features like adding, editing, deleting, and activating/deactivating operators.

