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:
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.
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_machines 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.
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.