Introduction to the Users Table
The Users table is designed to store and manage user information within the Serial application. This table plays a crucial role in user authentication, authorization, and profile management across the system.Table Structure
The Users table is structured to efficiently store user data and establish relationships with other key entities. Here’s a detailed breakdown of its columns:| Column Name | Data Type | Constraints | Description |
|---|---|---|---|
| supabase_uid | uuid | primary key | Unique identifier for each user |
| company_id | uuid | foreign key, nullable | Reference to the company the user belongs to |
| created_at | timestamp with time zone | not null, default now() | Timestamp of user creation |
| is_active | boolean | not null, default true | Indicates if the user account is active |
| text | not null | User’s email address | |
| first_name | text | nullable | User’s first name |
| last_name | text | nullable | User’s last name |
| role | text | not null, foreign key | User’s role in the system |
| default_station_id | uuid | foreign key, nullable | Reference to the user’s default station |
| title | text | nullable | User’s job title or position |
Usage and Functionality
The Users table is designed to be the central repository for user information and relationships. Here are some key points about its usage:-
User Authentication and Authorization: The table stores essential information used for authenticating users and determining their access rights within the application. The
rolecolumn, which references theuser_typestable, is crucial for implementing role-based access control. -
Company Association: Users are associated with companies through the
company_idforeign key. This allows for organization-specific data segregation and access control. -
Default Station Assignment: The
default_station_idallows users to have a predefined station, which can be used to streamline workflows or set default views in the application. -
Profile Management: With fields like
first_name,last_name,email, andtitle, the table supports comprehensive user profile management.
Notes
-
A trigger function named
handle_new_useris associated with this table to process new user data: -
The table has undergone migrations, notably from using
auth0_uidtosupabase_uidas the primary identifier, indicating an evolution in the authentication system. -
There’s a cascading delete relationship with the
auth.userstable, ensuring data consistency across the authentication and application layers.

