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 Name | Data Type | Constraints | Description |
|---|---|---|---|
| id | uuid | primary key, not null | Unique identifier for the work order |
| company_id | uuid | not null, foreign key | Reference to the associated company |
| wo_number | bigint | not null | Unique work order number |
| name | text | not null | Name of the work order |
| description | text | Optional description of the work order | |
| component_id | uuid | not null, foreign key | Reference to the associated component |
| part_number_id | uuid | foreign key | Optional reference to the associated part number |
| created_at | timestamp with time zone | not null, default now() | Timestamp of work order creation |
| created_by_user_id | uuid | not null | ID of the user who created the work order |
| status | text | not null, default ‘DRAFT’ | Current status of the work order |
| phase | text | Optional phase information | |
| quantity | bigint | not null | Quantity associated with the work order |
| approvals | jsonb | not null, default '' | JSON object storing approval information |
| assignee_user_id | uuid | foreign key | Optional reference to the assigned user |
| deadline | timestamp with time zone | Optional deadline for the work order | |
| activity_log | jsonb[] | not null | Array of JSON objects logging work order activities |
| last_edited_at | timestamp with time zone | Timestamp of the last edit to the work order | |
| attachments | jsonb[] | not null | Array 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:- Work Order Management: The table allows for the creation, tracking, and updating of work orders throughout their lifecycle, from draft to production.
- Approval Tracking: The approvals column stores JSON data to manage the approval process, allowing for multiple approvers and their status.
- Activity Logging: The activity_log column maintains a detailed history of actions and changes related to each work order, enhancing traceability.
- File Attachments: The attachments column supports storing multiple files associated with a work order, such as documentation or images.
- 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.

