Skip to main content

Introduction to the Work_Orders Table

The work_orders table is designed to store and manage work orders within the Serial application. This table plays a crucial role in tracking manufacturing processes, approvals, and associated components and part numbers.

Table Structure

The work_orders table is structured to capture comprehensive information about each work order. Here’s a detailed breakdown of its columns:
Column NameData TypeConstraintsDescription
iduuidprimary key, not nullUnique identifier for the work order
company_iduuidnot null, foreign keyReference to the associated company
wo_numberbigintnot nullUnique work order number
nametextnot nullName of the work order
descriptiontextOptional description of the work order
component_iduuidnot null, foreign keyReference to the associated component
part_number_iduuidforeign keyOptional reference to the associated part number
created_attimestamp with time zonenot null, default now()Timestamp of work order creation
created_by_user_iduuidnot nullID of the user who created the work order
statustextnot null, default ‘DRAFT’Current status of the work order
phasetextOptional phase information
quantitybigintnot nullQuantity associated with the work order
approvalsjsonbnot null, default ''JSON object storing approval information
assignee_user_iduuidforeign keyOptional reference to the assigned user
deadlinetimestamp with time zoneOptional deadline for the work order
activity_logjsonb[]not nullArray of JSON objects logging work order activities
last_edited_attimestamp with time zoneTimestamp of the last edit to the work order
attachmentsjsonb[]not nullArray of JSON objects storing attachment information

Usage and Functionality

The work_orders table is designed to be a comprehensive record of manufacturing tasks and their progress. Here are some key points about its usage:
  1. Work Order Management: The table allows for the creation, tracking, and updating of work orders throughout their lifecycle, from draft to production.
  2. Approval Tracking: The approvals column stores JSON data to manage the approval process, allowing for multiple approvers and their status.
  3. Activity Logging: The activity_log column maintains a detailed history of actions and changes related to each work order, enhancing traceability.
  4. File Attachments: The attachments column supports storing multiple files associated with a work order, such as documentation or images.
  5. Relational Integrity: Foreign key relationships ensure that work orders are properly associated with companies, components, part numbers, and users.

Notes

  • The wo_number is automatically incremented, ensuring a unique identifier for each work order within the system.
  • The status column allows for tracking the progress of work orders, with ‘DRAFT’ as the default initial status.
  • The activity_log and attachments columns use JSONB arrays, providing flexibility in storing varying amounts of data for each work order.
// Example of creating a new work order
const newWorkOrder = {
  company_id: "company-uuid",
  name: "New Assembly Process",
  component_id: "component-uuid",
  created_by_user_id: "user-uuid",
  quantity: 100,
  // Other fields...
};

const { data, error } = await supabase.from("work_orders").insert(newWorkOrder);
By leveraging the work_orders table, the Serial application can efficiently manage and track manufacturing processes, ensuring proper documentation, approval workflows, and traceability throughout the production lifecycle.