Skip to main content
The station_process_links table is designed to establish relationships between stations, processes, and components in the Serial application. This table plays a crucial role in managing the complex associations between these entities, enabling efficient querying and manipulation of production data.

Table Structure

The station_process_links table is structured to create many-to-many relationships between stations, processes, and components. Here’s a detailed breakdown of its columns:
Column NameData TypeConstraintsDescription
iduuidprimary key, not null, defaultUnique identifier for each link
company_iduuidnot null, foreign keyReferences the company associated with the link
station_iduuidnot null, foreign keyReferences the station involved in the link
component_iduuidnot null, foreign keyReferences the component involved in the link
process_iduuidnot null, foreign keyReferences the process involved in the link
process_revisionint8added laterStores the revision number of the associated process

Usage and Functionality

The station_process_links table is designed to be a central point for managing relationships between stations, processes, and components. Here are some key points about its usage:
  1. Relationship Management: It allows for flexible association of processes and components with specific stations, enabling complex production workflows.
  2. Querying Station Details: The table is crucial when fetching station information along with its associated processes and components. This is evident in functions like stations-page which retrieves detailed station data including linked processes.
  3. Production Validation: In the production app, this table is used to validate which processes are associated with a station, ensuring that only valid operations are performed.

Notes

  • Row-level security is enabled on the station_process_links table, ensuring data access is properly controlled.
  • There are specific policies for inserting, selecting, and deleting records based on user roles and company associations. For example:
    CREATE POLICY "Enable delete for users based on user_id" ON "public"."station_process_links"
    AS PERMISSIVE FOR DELETE
    TO public
    USING (EXISTS ( SELECT 1
       FROM privileges p
      WHERE ((p.company_id = station_process_links.company_id) AND (p.user_id = auth.uid()) AND (p.role = ANY (ARRAY['ADMIN'::text, 'ENGINEER'::text, 'TECHNICIAN'::text])))))
    
  • The table is involved in operations like linking all processes to a station or deleting specific station-process links, as seen in functions like linkAllProcesses and deleteStationProcessLink.
By leveraging the station_process_links table, the Serial application can efficiently manage and query the complex relationships between stations, processes, and components, providing a flexible and powerful foundation for production management and tracking.