The authentication system uses four core tables to manage users, sessions, OAuth accounts, and email verification. All tables use Drizzle ORM with PostgreSQL.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ashcroft08/provesa-web/llms.txt
Use this file to discover all available pages before exploring further.
User Table
Stores user profile information and credentials.Primary key. Unique identifier for the user.
User’s display name.
User’s email address. Must be unique.Constraints:
.unique()- No duplicate emails allowed
Whether the user’s email has been verified.
URL to user’s profile image/avatar.
When the user account was created.Default:
defaultNow()Last time the user record was updated.Default:
Auto-update: Updates automatically on any change
defaultNow()Auto-update: Updates automatically on any change
Relationships
- sessions - One-to-many relationship with
sessiontable - accounts - One-to-many relationship with
accounttable
Example Schema Usage
Session Table
Manages active user sessions with token-based authentication.Primary key. Unique session identifier.
When this session expires and should be invalidated.
Session token used for authentication.Constraints:
.unique()- Each token must be unique
When the session was created.Default:
defaultNow()Last activity timestamp for this session.Auto-update: Updates on any change
IP address from which the session was created.
Browser/client user agent string.
Foreign key reference to the user who owns this session.Constraints:
- References
user.id onDelete: 'cascade'- Deletes session when user is deleted
session_userId_idx- Indexed for fast user session lookups
Relationships
- user - Many-to-one relationship with
usertable
Example Usage
Account Table
Stores OAuth provider accounts and credentials linked to users.Primary key. Unique account identifier.
Account ID from the OAuth provider.
OAuth provider identifier (e.g., ‘google’, ‘github’, ‘credentials’).
Foreign key to the user who owns this account.Constraints:
- References
user.id onDelete: 'cascade'- Deletes account when user is deleted
account_userId_idx- Indexed for performance
OAuth access token from the provider.
OAuth refresh token for renewing access tokens.
OpenID Connect ID token.
When the access token expires.
When the refresh token expires.
OAuth scopes granted for this account.
Hashed password for credentials-based authentication.
When the account was linked.Default:
defaultNow()Last time the account was updated.Auto-update: Updates automatically
Relationships
- user - Many-to-one relationship with
usertable
Example Usage
Verification Table
Stores verification tokens for email verification, password resets, and other verification flows.Primary key. Unique verification record identifier.
What is being verified (usually an email address).Indexes:
verification_identifier_idx- Indexed for fast lookups
The verification token/code.
When this verification token expires.
When the verification was created.Default:
defaultNow()Last time the verification record was updated.Default:
Auto-update: Updates automatically
defaultNow()Auto-update: Updates automatically
Example Usage
Database Migration
To create these tables in your database:Migration SQL Example
Security Best Practices
Related
- Better Auth Documentation - The authentication library used
- Drizzle ORM Relations - Working with relationships
