Skip to main content

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 NameData TypeConstraintsDescription
iduuidprimary key, not null, default uuid_generate_v4()Unique identifier for each operator
first_nametextnot nullOperator’s first name
last_nametextOperator’s last name (optional)
pintextPersonal Identification Number for the operator (optional)
user_idtextforeign key (users.supabase_uid)Reference to the associated user account, if any
created_attimestamp with time zonenot null, default now()Timestamp of when the operator record was created
company_iduuidnot null, foreign key (companies.id)Reference to the company the operator belongs to
is_activebooleannot null, default trueIndicates 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:
  1. 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.
  2. Process Entry Association: Operators are linked to process entries, allowing for tracking of which operator performed specific actions or processes within the system.
  3. Active Status Management: The is_active column 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:
    export const validateOperator = async (operator) => {
      if (
        operator.pin === "" ||
        operator.pin == null ||
        operator.pin == undefined
      ) {
        return {
          isValid: false,
          messageType: "error",
          message: "Pin cannot be blank",
        };
      }
      const pnIsValid = await checkPinIsAvailable(operator);
      if (!pnIsValid) {
        return {
          isValid: false,
          messageType: "error",
          message: "This pin has already been assigned to another operator",
        };
      }
      return { isValid: true, messageType: "success", message: null };
    };
    
  • The OperatorTable component in the frontend provides a user interface for managing operators, including features like adding, editing, deleting, and activating/deactivating operators.
By leveraging the operators table, the Serial application efficiently manages operator information across different companies, ensuring secure and flexible operator tracking without the overhead of creating full user accounts for each operator. This approach streamlines the process of managing personnel involved in various manufacturing and quality control processes.