Schema Organization
The database schema is defined in TypeScript files located atsrc/database/schemas/. Each schema file represents a logical grouping of related tables.
Authentication Tables
user
Core user account table with authentication and profile data.Primary key for the user
User’s display name
User’s email address (unique)
Whether the email has been verified
Profile image URL
Unique username (unique)
Display version of username
User role for permissions
Whether the user is banned
Reason for ban
When the ban expires
Account creation timestamp
Last update timestamp (auto-updated)
session
User session management with device tracking.Primary key for the session
Session token (unique)
Session expiration timestamp
Foreign key to user table (cascade delete)
IP address of the session
Browser/device user agent
Currently active organization for this session
User ID if this session is an impersonation
Session creation timestamp
Last activity timestamp
session_userId_idxonuserId
account
OAuth provider accounts linked to users.Primary key
Provider-specific account ID
OAuth provider identifier (google, github, etc.)
Foreign key to user (cascade delete)
OAuth access token
OAuth refresh token
OAuth ID token
Access token expiration
Refresh token expiration
OAuth scope granted
Hashed password for credential-based auth
Account link creation timestamp
Last update timestamp
account_userId_idxonuserId
verification
Email verification and password reset tokens.Primary key
Email or identifier to verify
Verification token/code
Token expiration timestamp
When the token was used (null if unused)
Token creation timestamp
Last update timestamp
verification_identifier_idxonidentifier
organization
Multi-tenant organization/workspace management.Primary key
Organization name
URL-friendly slug (unique)
Logo URL
Organization creation timestamp
Additional organization metadata (JSON string)
organization_slug_uidxunique index onslug
member
Organization membership and roles.Primary key
Foreign key to organization (cascade delete)
Foreign key to user (cascade delete)
Member role (member, admin, owner, etc.)
Membership creation timestamp
member_organizationId_idxonorganizationIdmember_userId_idxonuserId
invitation
Pending organization invitations.Primary key
Foreign key to organization (cascade delete)
Invited email address
Role to grant upon acceptance
Invitation status (pending, accepted, rejected)
Invitation expiration timestamp
Foreign key to user who sent the invitation (cascade delete)
Invitation creation timestamp
invitation_organizationId_idxonorganizationIdinvitation_email_idxonemail
rate_limit
Rate limiting tracking table.Primary key
Rate limit key (IP, user ID, etc.)
Request count
Timestamp of last request (milliseconds)
audit_logs
Audit trail for important actions.Primary key
Action performed (e.g., “user.created”, “post.published”)
User who performed the action
ID of the affected resource
IP address of the request
User agent string
Additional action data as JSON
Action timestamp
Profile Table
profile
Extended user profile information beyond core auth.Primary key
Foreign key to user (unique)
Profile username
User’s full name
Biography/about text
Avatar image URL
User location
Personal website URL
Preferred UI language
Profile creation timestamp
Last update timestamp (auto-updated)
Blog Tables
blog_posts
Main blog post content table.Primary key
URL slug (unique)
Publication status (draft, published, archived)
Foreign key to blog_organizations
Publication timestamp
Show on homepage
Show in blog listing
Featured post flag
Estimated reading time
Article word count
Schema.org time required field
Whether comments are enabled
Primary language code
Content license
External discussion URL
Canonical URL
External identifier
Post creation timestamp
Last update timestamp
idx_blog_posts_slugunique onslugidx_blog_posts_statusonstatusidx_blog_posts_published_atonpublishedAtidx_blog_posts_homeondisplayInHomeidx_blog_posts_featuredonisFeatured
blog_post_authors
Join table linking posts to authors (many-to-many).Foreign key to blog_posts
Foreign key to blog_authors
idx_blog_post_authors_postonpostIdidx_blog_post_authors_authoronauthorId
blog_post_categories
Join table linking posts to categories (many-to-many).Foreign key to blog_posts
Foreign key to blog_categories
idx_blog_post_categories_postonpostIdidx_blog_post_categories_categoryoncategoryId
blog_post_media
Join table linking posts to media (many-to-many).Foreign key to blog_posts
Foreign key to blog_media
Media type (cover, inline, etc.)
Position/order in post
idx_blog_post_media_postonpostIdidx_blog_post_media_mediaonmediaId
blog_authors
Blog author profiles.Primary key
URL slug (unique)
First name (multilingual)
Last name (multilingual)
Display name (multilingual)
Biography (multilingual)
Job title (multilingual)
Contact email (unique)
Foreign key to blog_media
Direct avatar URL
Personal website
Social media links array
Foreign key to blog_organizations
Show on homepage
Show in blog
Featured author flag
SEO title (multilingual)
SEO description (multilingual)
SEO keywords (multilingual)
Canonical URL (multilingual)
Creation timestamp
Update timestamp
idx_blog_authors_slugunique onslugidx_blog_authors_homeondisplayInHomeidx_blog_authors_featuredonisFeaturedidx_blog_authors_emailonemail
blog_categories
Blog post categories with hierarchical support.Primary key
URL slug (unique)
Category name (multilingual)
Category description (multilingual)
Foreign key to blog_media
Show on homepage
Show in navigation menu
Show in blog
Featured category flag
Foreign key to parent category (self-reference)
SEO title (multilingual)
SEO description (multilingual)
SEO keywords (multilingual)
Canonical URL (multilingual)
Creation timestamp
Update timestamp
idx_blog_categories_slugunique onslugidx_blog_categories_parentonparentIdidx_blog_categories_homeondisplayInHomeidx_blog_categories_featuredonisFeatured
blog_comments
Universal comments table supporting threading.Primary key
ID of the related entity
Type of entity (blog, place, event, hike, classified)
Foreign key to parent comment for threading
Comment author name
Comment author email
Comment content (multilingual)
Optional rating (0-5)
Moderation status (pending, approved, rejected)
Comment language
Creation timestamp
Update timestamp
idx_blog_comments_entityonpostIdidx_blog_comments_typeonpostTypeidx_blog_comments_statusonstatusidx_blog_comments_parentonparentId
blog_media
Media assets for blog content.Primary key
Media URL
Alternative content URL
Media type (image, video, audio)
MIME type
Image/video width
Image/video height
Video/audio duration
Media license
Copyright holder name
Media caption (multilingual)
Media description (multilingual)
Alt text for accessibility (multilingual)
Thumbnail URL
Upload timestamp
Update timestamp
idx_blog_media_typeontypeidx_blog_media_urlonurl
blog_translations
Multilingual translations for blog posts.Primary key
Foreign key to blog_posts
Language code (fr, en, etc.)
Post headline (translated)
Alternative headline
Full article content (translated)
Post excerpt (translated)
SEO title (translated)
SEO description (translated)
SEO keywords (translated)
Canonical URL (translated)
Translation creation timestamp
Translation update timestamp
idx_blog_translations_postonpostIdidx_blog_translations_languageoninLanguage
blog_organizations
Schema.org-compatible organization profiles for blog publishers.Active status
Featured flag
Creation timestamp
Update timestamp (auto-updated)
Services Tables
services_listings
Service marketplace listings.Primary key
URL slug (unique)
Foreign key to services_categories
Service provider user ID
Foreign key to blog_organizations
Listing status (pending_review, active, inactive)
Base price
Pricing model (fixed, hourly, etc.)
Currency code
Service duration in minutes
Mobile service flag
Maximum participants
Minimum advance booking hours
Cancellation notice hours
Active status
Featured listing flag
Show on homepage
Allow customer reviews
Primary language
Creation timestamp
Update timestamp
idx_services_listings_slugunique onslugidx_services_listings_statusonstatusidx_services_listings_categoryoncategoryIdidx_services_listings_provideronproviderIdidx_services_listings_orgonorganizationIdidx_services_listings_featuredonisFeaturedidx_services_listings_homeondisplayInHomeidx_services_listings_activeonisActive
services_media_links
Join table linking services to media.Foreign key to services_listings
Foreign key to services_media
Media type (cover, gallery)
Display position/order
idx_services_media_links_serviceonserviceIdidx_services_media_links_mediaonmediaId
services_categories
Service category taxonomy with hierarchy.Primary key
URL slug (unique)
Category name (multilingual)
Category description (multilingual)
Icon identifier
Foreign key to services_media
Parent category ID (self-reference)
Display sort order
Show on homepage
Show in menu
Active status
Featured flag
SEO title (multilingual)
SEO description (multilingual)
Creation timestamp
Update timestamp
idx_services_categories_slugunique onslugidx_services_categories_parentonparentIdidx_services_categories_sortonsortOrderidx_services_categories_activeonisActive
services_reviews
Service reviews and ratings with threading.Primary key
Foreign key to services_listings
Parent review ID for replies
Reviewer name
Reviewer email
Reviewer user ID
Review content (multilingual)
Rating (1-5)
Moderation status (pending, approved, rejected)
Review language
Review creation timestamp
Update timestamp
idx_services_reviews_serviceonserviceIdidx_services_reviews_statusonstatusidx_services_reviews_ratingonratingidx_services_reviews_parentonparentIdidx_services_reviews_authoronauthorId
services_availability
Service provider availability schedule.Primary key
Foreign key to services_listings
Day of week (0=Sunday, 6=Saturday)
Start time (HH:MM format)
End time (HH:MM format)
Availability flag
Creation timestamp
idx_services_availability_uniqueunique on (serviceId,dayOfWeek,startTime)idx_services_availability_serviceonserviceId
services_bookings
Service booking records.Primary key
Foreign key to services_listings
Customer user ID
Provider user ID
Booking date (YYYY-MM-DD)
Booking time (HH:MM)
Booking duration in minutes
Total booking price
Currency code
Booking status (pending, confirmed, cancelled, completed)
Message from customer
Response from provider
Cancellation timestamp
Completion timestamp
Booking creation timestamp
Update timestamp
idx_services_bookings_serviceonserviceIdidx_services_bookings_customeroncustomerIdidx_services_bookings_provideronproviderIdidx_services_bookings_statusonstatusidx_services_bookings_dateonbookingDate
services_media
Media assets for service listings.Primary key
Media URL
Alternative content URL
Media type (image, video, audio)
MIME type
Width in pixels
Height in pixels
Video/audio duration
Media license
Copyright holder
Media caption (multilingual)
Media description (multilingual)
Alt text (multilingual)
Thumbnail URL
Upload timestamp
Update timestamp
idx_services_media_typeontypeidx_services_media_urlonurl
services_translations
Multilingual translations for service listings.Primary key
Foreign key to services_listings
Language code
Service title (translated)
Full description (translated)
Short description (translated)
SEO title (translated)
SEO description (translated)
SEO keywords (translated)
Canonical URL (translated)
Translation creation timestamp
Update timestamp
idx_services_translations_serviceonserviceIdidx_services_translations_languageoninLanguage
Notification Table
notification
User notification system.Primary key
Target user ID
Notification type (email, push, in-app, etc.)
Notification title
Notification body content
Additional message text
Delivery status (sent, pending, failed)
Type of related entity (post, booking, etc.)
ID of related entity
Additional notification data as JSON
Read status
When notification was read
Notification creation timestamp
Update timestamp
Data Types Reference
Common Types
- text: Variable-length text field
- integer: 32-bit integer
- bigint: 64-bit integer
- boolean: True/false value
- timestamp: Date and time with timezone
- jsonb: Binary JSON for structured data (indexed, supports multilingual content)
JSONB Usage
Many fields usejsonb type to support multilingual content:
Cascade Deletion
Foreign keys with{ onDelete: "cascade" } automatically delete child records:
- Deleting a user deletes all their sessions, accounts, and memberships
- Deleting an organization deletes all members and invitations
- Deleting a service listing deletes all bookings and reviews
Schema Files
All schema definitions are located in:Next Steps
Migrations
Learn how to generate and run database migrations
Relationships
Understand table relationships and foreign keys