Skip to main content

Database schema overview

This reference provides an overview of Cinephage's database structure, including major tables and their relationships.

Database Information

  • Engine: SQLite 3
  • Location: /config/data/cinephage.db (Docker) or data/cinephage.db (local)
  • Format: Single-file database
  • Backup: Simple file copy when Cinephage is stopped

Schema Version

Cinephage uses schema versioning for migrations:

  • Current schema version is stored in database metadata
  • Automatic migrations run on startup when needed
  • Backward compatibility maintained within major versions

Major Table Categories

Authentication (Better Auth)

User authentication and session management:

TablePurpose
userUser accounts and profile data
sessionActive authentication sessions
accountOAuth/SSO account links
verificationEmail verification tokens
apikeyAPI key storage
rateLimitRate limiting data

Library

Core media library data:

TablePurpose
moviesMovie metadata and monitoring status
movie_filesPhysical movie files
seriesTV series metadata
seasonsSeason information
episodesEpisode metadata
episode_filesPhysical episode files
root_foldersConfigured root folders
unmatched_filesFiles awaiting manual matching
library_scan_historyScan operation history

Downloads

Download client integration:

TablePurpose
download_queueActive downloads
download_historyCompleted downloads
download_clientsDownload client configurations
blocklistFailed/problematic releases
pending_releasesReleases awaiting download

Indexers

Content source management:

TablePurpose
indexer_definitionsYAML indexer definitions cache
indexersConfigured indexer instances
indexer_statusHealth status tracking

Quality

Scoring and quality management:

TablePurpose
scoring_profilesQuality profile definitions
profile_size_limitsSize constraints per profile
custom_formatsCustom format rules
delay_profilesDownload delay settings

Monitoring

Automated task management:

TablePurpose
monitoring_settingsTask configuration
monitoring_historyTask execution history
task_settingsBackground task settings
task_historyTask run history

Subtitles

Subtitle management:

TablePurpose
language_profilesLanguage preference profiles
subtitle_providersProvider configurations
subtitlesDownloaded subtitle records
subtitle_historyDownload history
subtitle_blacklistRejected subtitle entries
subtitle_settingsGlobal subtitle settings

Smart Lists

Dynamic content lists:

TablePurpose
smart_listsList definitions
smart_list_itemsItems in each list
smart_list_refresh_historyList update history

Streaming

Streaming and NZB streaming:

TablePurpose
stream_extraction_cacheStream processing cache
nntp_serversUsenet server configurations
nzb_stream_mountsNZB streaming mounts
nzb_segment_cacheSegment caching for streaming

Live TV

IPTV and live television:

TablePurpose
stalker_portalsStalker portal configurations
portal_scan_resultsMAC address scan results
portal_scan_historyScan operation history
livetv_accountsLive TV account configs (unified)
livetv_channelsChannel information
livetv_categoriesChannel categories
channel_categoriesUser category assignments
channel_lineup_itemsUser channel lineups
channel_lineup_backupsBackup source configurations
epg_programsElectronic program guide data

System

Application settings and metadata:

TablePurpose
settingsApplication settings
library_settingsLibrary-specific settings
naming_settingsFile naming configuration
naming_presetsBuilt-in naming presets
captcha_solver_settingsCaptcha solver config
media_browser_serversJellyfin/Emby connections
external_id_cacheTMDB external ID cache
alternate_titlesTitle aliases
userApiKeySecretsAPI key secrets

Key Relationships

Movie Relationships

movies
├── movie_files (one-to-many)
├── subtitles (many-to-many)
└── root_folders (many-to-one)

TV Series Relationships

series
├── seasons (one-to-many)
│ └── episodes (one-to-many)
│ ├── episode_files (one-to-many)
│ └── subtitles (many-to-many)
└── root_folders (many-to-one)

Download Flow

movies/episodes
└── download_queue (one-to-one while downloading)
├── download_clients (many-to-one)
└── download_history (becomes history entry)

Common Queries

List All Movies

SELECT id, title, year, monitored, tmdbId
FROM movies
ORDER BY title;

Count Monitored Items

SELECT
(SELECT COUNT(*) FROM movies WHERE monitored = 1) as monitored_movies,
(SELECT COUNT(*) FROM series WHERE monitored = 1) as monitored_series;

Recent Downloads

SELECT
dh.id,
dh.title,
dh.quality,
dh.date
FROM download_history dh
ORDER BY dh.date DESC
LIMIT 10;

Files Missing Quality Info

SELECT
m.title,
m.year
FROM movies m
LEFT JOIN movie_files mf ON m.id = mf.movieId
WHERE m.monitored = 1
AND (mf.id IS NULL OR mf.quality IS NULL);

Database Size Estimates

Typical database sizes:

Library SizeDatabase SizeNotes
100 movies1-2 MBMinimal
1,000 movies5-10 MBSmall library
10,000 movies20-50 MBMedium library
50,000+ movies100-200 MBLarge library

Size factors:

  • Number of movies/series/episodes
  • Download history retention
  • Subtitle records
  • Cache tables

Backup and Maintenance

Creating Backups

# While Cinephage is stopped
cp /path/to/config/data/cinephage.db /path/to/backups/cinephage-$(date +%Y%m%d).db

# Or use SQLite online backup (while running)
sqlite3 /path/to/config/data/cinephage.db ".backup /path/to/backups/cinephage-$(date +%Y%m%d).db"

Database Optimization

# Vacuum (reclaim space, optimize)
sqlite3 /path/to/config/data/cinephage.db "VACUUM;"

# Analyze (update statistics)
sqlite3 /path/to/config/data/cinephage.db "ANALYZE;"

Run optimization monthly or after large imports.

Integrity Check

# Check for corruption
sqlite3 /path/to/config/data/cinephage.db "PRAGMA integrity_check;"

# Should return "ok"

Accessing the Database

Docker Access

# Enter container shell
docker exec -it cinephage sh

# Access database
sqlite3 /config/data/cinephage.db

# Or run query directly
docker exec cinephage sqlite3 /config/data/cinephage.db "SELECT COUNT(*) FROM movies;"

Local Access (if not using Docker)

# Direct access
sqlite3 /path/to/config/data/cinephage.db

Schema Migrations

Cinephage handles schema migrations automatically:

  1. Current version stored in database
  2. On startup, check if migrations needed
  3. Apply pending migrations in order
  4. Update version number
warning
  • Back up before major version upgrades
  • Do not manually modify schema
  • Report migration errors as bugs

See Also