a3eb4b1b57
- Added Jellyfin.Database.Providers.Postgres project with full EF Core migration support for PostgreSQL. - Implemented automatic database creation and privilege assignment on startup. - Generated initial migration and model snapshot for PostgreSQL schema. - Updated build, test, and dependency files to include PostgreSQL provider and Npgsql packages. - Added PowerShell script for generating and testing PostgreSQL migrations. - No changes to application logic outside database provider/migration infrastructure.
4.0 KiB
4.0 KiB
Quick Start: PostgreSQL with Jellyfin
🚀 Fastest Setup Ever (2 Steps!)
Step 1: Create PostgreSQL User
psql -U postgres -c "CREATE USER jellyfin WITH PASSWORD 'your_password' CREATEDB;"
Step 2: Configure Jellyfin
Create/Edit config/database.xml:
<?xml version="1.0" encoding="utf-8"?>
<DatabaseConfigurationOptions>
<DatabaseType>Jellyfin-PostgreSQL</DatabaseType>
<LockingBehavior>NoLock</LockingBehavior>
<CustomProviderOptions>
<Options>
<CustomDatabaseOption>
<Key>host</Key>
<Value>localhost</Value>
</CustomDatabaseOption>
<CustomDatabaseOption>
<Key>port</Key>
<Value>5432</Value>
</CustomDatabaseOption>
<CustomDatabaseOption>
<Key>database</Key>
<Value>jellyfin</Value>
</CustomDatabaseOption>
<CustomDatabaseOption>
<Key>username</Key>
<Value>jellyfin</Value>
</CustomDatabaseOption>
<CustomDatabaseOption>
<Key>password</Key>
<Value>your_password</Value>
</CustomDatabaseOption>
</Options>
</CustomProviderOptions>
</DatabaseConfigurationOptions>
Step 3: Start Jellyfin
./jellyfin
That's it! Jellyfin automatically:
- ✅ Creates the database
- ✅ Creates all 30 tables
- ✅ Sets up indexes
- ✅ Grants permissions
What Jellyfin Does Automatically
Starting Jellyfin...
↓
Checking if database 'jellyfin' exists...
↓
Database not found - Creating...
↓
✅ Database created!
✅ Permissions granted!
↓
Applying migrations...
↓
✅ All 30 tables created!
↓
Jellyfin ready!
Docker Compose
version: '3'
services:
postgres:
image: postgres:15
environment:
POSTGRES_USER: jellyfin
POSTGRES_PASSWORD: secure_password
# No POSTGRES_DB needed - Jellyfin creates it!
volumes:
- postgres_data:/var/lib/postgresql/data
jellyfin:
image: jellyfin/jellyfin:latest
depends_on:
- postgres
volumes:
- jellyfin_config:/config
# Configure PostgreSQL via config/database.xml
volumes:
postgres_data:
jellyfin_config:
Verification
Check Database Exists
psql -U jellyfin -l | grep jellyfin
# Output: jellyfin | jellyfin | UTF8 | ...
Check Tables
psql -U jellyfin -d jellyfin -c "\dt"
# Output: List of 30 tables
Check Logs
tail -f <jellyfin-log-directory>/log_*.txt | grep PostgreSQL
Expected:
[INFO] Checking if PostgreSQL database exists...
[INFO] PostgreSQL database 'jellyfin' does not exist. Creating...
[INFO] PostgreSQL database 'jellyfin' created successfully
Common Issues
❌ "permission denied to create database"
Fix:
ALTER USER jellyfin CREATEDB;
❌ "role 'jellyfin' does not exist"
Fix: Create the user (Step 1)
❌ "could not connect to server"
Fix:
- Check PostgreSQL is running:
systemctl status postgresql - Check host/port in config
- Check firewall
Pro Tips
Production Security
After first successful start, you can revoke CREATEDB:
ALTER USER jellyfin WITH NOCREATEDB;
Custom Database Name
Want to use a different database name?
<CustomDatabaseOption>
<Key>database</Key>
<Value>my_custom_jellyfin_db</Value>
</CustomDatabaseOption>
Multiple Jellyfin Instances
Each instance needs its own database:
CREATE USER jellyfin1 WITH PASSWORD 'pass1' CREATEDB;
CREATE USER jellyfin2 WITH PASSWORD 'pass2' CREATEDB;
Configure each with different database names:
- Instance 1:
database=jellyfin1 - Instance 2:
database=jellyfin2
Full Documentation
- 📖 DATABASE_CONFIGURATION.md - Complete setup guide
- 📖 AUTOMATIC_DATABASE_CREATION.md - Feature details
- 📖 POSTGRESQL_TROUBLESHOOTING.md - Problem solving
Summary
Before: 6 manual SQL commands + configuration
Now: 1 SQL command + configuration
That's 83% less work! 🎉