Events
Events are time-stamped records of what happens at stations and machines. All event types share the same table (oee_machine_events) with type-specific columns. Events are not machine-specific — they can belong to stations, machines, or both.
Event Types
There are three event types, each with distinct ownership and behavior rules:
| Aspect | Downtime | Incidents | Jobs |
|---|---|---|---|
| Belongs to | Multiple machines and/or stations | Multiple machines and/or stations | One station at a time |
| Simultaneous resources | N/A | N/A | Multiple machines + people contribute time |
| Cross-station tracking | N/A | N/A | Via job_number |
| Completing | Resolving the event | Resolving the event | Finishing at this station |
1. Job (event_type = 'job')
Production run events at a Station. A job belongs to one station at a time — it cannot span multiple stations simultaneously. However, multiple machines and people contribute hours towards the same job at that station. Hours are cumulative: 3 people x 2 hours = 6 person-hours.
Completing a job means finishing it at the current station. Tracking a job across stations is done by job_number — see Job Number Tracking below.
Extended by oee_batch_details table with:
product_id(UUID, NOT NULL, FK toops_products) — every batch must reference a product. See Product Hierarchy.batch_number,work_ordertarget_quantity,good_parts,scrap_parts,total_partsstatus:running,completed,abortedabort_reason_id,scrap_reason_id
See OEE Job for full details.
2. Downtime (event_type = 'downtime')
Periods where a station or machine is not producing. A single downtime event can be linked to multiple machines and/or stations simultaneously — for example, a power outage affecting several machines and the stations they belong to.
Uses:
downtime_reason_id(FK tooee_downtime_reasons)
The downtime type (planned/unplanned/idle) is inherited from the parent group. See Downtime Reason.
Operators can log downtime from the My Shifts downtime panel against the selected station. The reason list is filtered by the selected station when a Downtime Reason is configured for specific stations. Reasons with no station availability list remain available at every station on the site. If planned and unplanned versions share the same reason code and name, the logging modal displays one reason row and stores the selected planned or unplanned reason ID based on the row toggle.
The My Shifts downtime panel station list uses the selected My Shifts date range. Each station row summarizes matching downtime events by total count, planned count, unplanned count, active count, and unknown reason type count; stations with no matching events show a no-downtime state.
Downtime events may still be linked to additional affected machines or stations through the event-equipment junction. Active downtime counts are calculated from the event’s primary station and linked affected resources.
Downtime records keep one notes history across the event lifecycle:
notesstores the initial context captured when downtime is loggedtroubleshooting_notesstores investigation details added while troubleshooting or resolvingresolution_notesstores the required closeout summary when the downtime is resolved
The event details view and station downtime panel display these note types together as the event’s notes history. The resolve workflow keeps the same notes history together, allows the initial notes and troubleshooting notes to be updated, and requires the resolution notes field as the closeout record.
3. Incident (event_type = 'incident')
Notable occurrences logged against stations or machines. A single incident can be linked to multiple machines and/or stations simultaneously — for example, a quality issue affecting multiple machines across stations.
Uses:
incident_reason_id(FK tooee_incident_reasons)troubleshooting_started_at/by— Investigation trackingtroubleshooting_notesresolved_at/by— Resolution trackingresolution_notes
See Incident Reason for the taxonomy.
Job Number Tracking
The job_number (stored as batch_number in oee_batch_details) is how work is tracked as it moves through a process flow. Jobs with the same job_number at different stations represent the same work moving through the system.
- A job exists at one station at a time — it is created, worked on, and completed at that station
- When the same work moves to the next station, a new job event is created there with the same
job_number - Querying all jobs with a given
job_numberacross stations reveals the full journey of that work through the site
Database Table: oee_machine_events
| Column | Type | Description |
|---|---|---|
id | UUID (PK) | Auto-generated |
organization_id | VARCHAR(50) | Org ownership |
site_id | UUID (FK) | References Site |
machine_id | UUID (FK) | Which Machine (nullable for station-only events) |
event_type | VARCHAR(20) | 'job', 'downtime', or 'incident' |
job_id | UUID (FK, nullable) | Direct link to a job (ops_jobs) |
start_ts | TIMESTAMPTZ | Event start time |
end_ts | TIMESTAMPTZ | Event end time (NULL = active/running) |
duration_minutes | DECIMAL(10,2) | Calculated duration |
notes | TEXT | Free-text notes |
is_archived | BOOLEAN | Soft-delete flag |
created_by / completed_by | VARCHAR(50) | Who created/closed the event |
Multi-Resource Events
The oee_machine_event_equipment junction table allows a single event to be associated with multiple machines and/or stations. For downtime and incident events, this enables recording that multiple resources are affected simultaneously. Station downtime views include events where the station is either the primary event equipment or one of the linked affected stations.
Status Derivation
Event status is derived from timestamps, not stored as a separate field:
- Active/Running:
end_ts IS NULL - Completed/Closed:
end_ts IS NOT NULL
Key Indexes
(machine_id, start_ts DESC)— timeline queriesmachine_id WHERE end_ts IS NULL— active eventsevent_type— type-specific filteringjob_id— cross-referencing with OPS jobs
Codebase Paths
- Table:
database/sql_scripts/tables/oee_machine_events.sql - Batch details:
database/sql_scripts/tables/oee_batch_details.sql - Multi-resource junction:
database/sql_scripts/tables/oee_machine_event_machines.sql
History
This page was previously titled “Machine Events” when events were modeled as machine-centric.