Database Schema
Overview of the database schema and types used in the application
All database types are automatically inferred using Drizzle's
$inferSelect
utility, ensuring type safety across the application.Core Schemas
Users & Authentication
users
- Core user information and profilesauth
- Authentication-related tables and sessions
Workspaces
workspaces
- Workspace configuration and settingsworkspaceMembers
- Workspace membership and rolesinvitations
- Pending workspace invitations
Permissions & Access Control
permissions
- RBAC permissions definitionsroles
- User roles and capabilities
Feature Schemas
Notifications
notifications
- User notificationsuserNotificationSettings
- Notification preferences
Billing & Subscriptions
subscriptions
- Workspace subscription details
Integration
items
- Generic items storage
Type Definitions
Inferred Types
The following TypeScript types are automatically inferred from the schema:
TYPESCRIPT
Schema Organization
File Structure
All schema definitions are organized in separate files under server/drizzle/schema/
and exported through a central index.ts
file. This modular approach allows for:
- 1Better code organization and maintainability
- 2Easier schema updates and migrations
- 3Clear separation of concerns
- 4Type-safe database operations
Key Features
🔄
Type Safety
Full TypeScript integration with Drizzle ORM
📊
Schema Migrations
Automated migration generation and application
🔍
Query Building
Type-safe query building with autocompletion
🛡️
Validation
Runtime validation with Zod integration
When adding new tables or modifying existing ones, make sure to:
- 1Update the schema files
- 2Generate and run migrations
- 3Update type definitions if needed