Introduction to the Alerts Table
The alerts table is designed to store and manage notifications or alerts within the Serial application. This table plays a crucial role in the system by providing a centralized location for storing important messages that need to be communicated to users, often in relation to specific companies or events.Table Structure
The alerts table is structured to efficiently store alert information while maintaining relationships with other entities in the database. Here’s a detailed breakdown of its columns:Usage and Functionality
The alerts table is designed to be flexible and integrated with the application’s notification system. Here are some key points about its usage:-
Alert Creation: Alerts can be created programmatically using the
createAlertfunction insupabaseAlerts.ts. This function allows specifying the company ID, message, type, link, and relevant IDs. -
Alert Retrieval: The application can fetch alerts using functions like
fetchAlertsorfetchAlertsByRelevantIds. This allows for efficient retrieval of all alerts or filtering based on specific criteria. -
Alert Management: Alerts can be deactivated using functions like
deactivateAlertsByRelevantIdsordeactivateAlertsById. This allows for maintaining a history of alerts while controlling which ones are currently active. -
Frontend Integration: The
HomeAlertscomponent in the frontend displays active alerts to users. It uses the alert type to determine the appropriate visual style (e.g., warning banner for “OVERRIDE” alerts).
Notes
- Row-level security is enabled on the alerts table, ensuring that alerts are only accessible to users with appropriate permissions.
-
The table supports different types of alerts, which can be extended as needed. For example:
-
The
relevant_idscolumn allows linking alerts to specific entities or events in the system, providing context for the alert.

