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/cinephage.db
  • 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
authApiKeysAPI key storage
authRateLimitsRate limiting data

Library

Core media library data:

TablePurpose
moviesMovie metadata and monitoring status
movieFilesPhysical movie files
seriesTV series metadata
seasonsSeason information
episodesEpisode metadata
episodeFilesPhysical episode files
rootFoldersConfigured root folders
unmatchedFilesFiles awaiting manual matching
libraryScanHistoryScan operation history

Downloads

Download client integration:

TablePurpose
downloadQueueActive downloads
downloadHistoryCompleted downloads
downloadClientsDownload client configurations
blocklistFailed/problematic releases
pendingReleasesReleases awaiting download

Indexers

Content source management:

TablePurpose
indexerDefinitionsYAML indexer definitions cache
indexersConfigured indexer instances
indexerStatusHealth status tracking

Quality

Scoring and quality management:

TablePurpose
scoringProfilesQuality profile definitions
profileSizeLimitsSize constraints per profile
customFormatsCustom format rules
delayProfilesDownload delay settings

Monitoring

Automated task management:

TablePurpose
monitoringSettingsTask configuration
monitoringHistoryTask execution history
taskSettingsBackground task settings
taskHistoryTask run history

Subtitles

Subtitle management:

TablePurpose
languageProfilesLanguage preference profiles
subtitleProvidersProvider configurations
subtitlesDownloaded subtitle records
subtitleHistoryDownload history
subtitleBlacklistRejected subtitle entries
subtitleSettingsGlobal subtitle settings

Smart Lists

Dynamic content lists:

TablePurpose
smartListsList definitions
smartListItemsItems in each list
smartListRefreshHistoryList update history

Streaming

Streaming and NZB streaming:

TablePurpose
streamExtractionCacheStream processing cache
nntpServersUsenet server configurations
nzbStreamMountsNZB streaming mounts
nzbSegmentCacheSegment caching for streaming

Live TV

IPTV and live television:

TablePurpose
stalkerPortalsStalker portal configurations
portalScanResultsMAC address scan results
portalScanHistoryScan operation history
livetvAccountsLive TV account configs (unified)
livetvChannelsChannel information
livetvCategoriesChannel categories
channelCategoriesUser category assignments
channelLineupItemsUser channel lineups
channelLineupBackupsBackup source configurations
epgProgramsElectronic program guide data

System

Application settings and metadata:

TablePurpose
settingsApplication settings
librarySettingsLibrary-specific settings
namingSettingsFile naming configuration
namingPresetsBuilt-in naming presets
captchaSolverSettingsCaptcha solver config
mediaBrowserServersJellyfin/Emby connections
externalIdCacheTMDB external ID cache
alternateTitlesTitle aliases
userApiKeySecretsAPI key secrets

Key Relationships

Movie Relationships

movies
├── movieFiles (one-to-many)
├── subtitles (many-to-many)
└── rootFolders (many-to-one)

TV Series Relationships

series
├── seasons (one-to-many)
│ └── episodes (one-to-many)
│ ├── episodeFiles (one-to-many)
│ └── subtitles (many-to-many)
└── rootFolders (many-to-one)

Download Flow

movies/episodes
└── downloadQueue (one-to-one while downloading)
├── downloadClients (many-to-one)
└── downloadHistory (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 downloadHistory dh
ORDER BY dh.date DESC
LIMIT 10;

Files Missing Quality Info

SELECT
m.title,
m.year
FROM movies m
LEFT JOIN movieFiles 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/cinephage.db /path/to/backups/cinephage-$(date +%Y%m%d).db

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

Database Optimization

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

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

Run optimization monthly or after large imports.

Integrity Check

# Check for corruption
sqlite3 /path/to/config/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/cinephage.db

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

Local Access (if not using Docker)

# Direct access
sqlite3 /path/to/config/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

Important:

  • Back up before major version upgrades
  • Do not manually modify schema
  • Report migration errors as bugs

See Also