Files
pgsql-jellyfin/src/Jellyfin.Database/Jellyfin.Database.Providers.Postgres
wjones db3b19dbb0 Migrate all projects and tests to .NET 11.0
Upgraded the target framework for all main, test, and provider projects from .NET 10.0 (net10.0) to .NET 11.0 (net11.0). Updated all major NuGet dependencies to their .NET 11-compatible versions, including Microsoft.AspNetCore.*, Microsoft.EntityFrameworkCore.*, Microsoft.Extensions.*, Serilog, System.Text.Json, and Npgsql.EntityFrameworkCore.PostgreSQL (now 11.0.0-preview.1). Regenerated all project.assets.json, NuGet cache, and MSBuild files to reflect the new framework and package versions. Removed or updated incompatible dependencies and references. Set allWarningsAsErrors: true in NuGet spec files for stricter builds. No application logic changes were made; all updates are related to project configuration, dependency management, and build system modernization for .NET 11.0.
2026-02-20 17:55:22 -05:00
..

Jellyfin.Database.Providers.Postgres

PostgreSQL database provider for Jellyfin.

⚠️ Important Note

This provider currently uses Npgsql.EntityFrameworkCore.PostgreSQL 9.0.2 with EF Core 10.0.3, which requires overriding package version constraints. This is a temporary workaround until Npgsql releases a version compatible with EF Core 10.

Compatibility Warning: This may cause runtime issues. Monitor for:

  • Npgsql.EntityFrameworkCore.PostgreSQL 10.x release
  • Update Directory.Packages.props when available

Configuration

To use PostgreSQL as the database backend, configure the following options in your Jellyfin configuration:

{
  "Database": {
    "Provider": "Jellyfin-PostgreSQL",
    "CustomProviderOptions": {
      "Options": [
        { "Key": "host", "Value": "localhost" },
        { "Key": "port", "Value": "5432" },
        { "Key": "database", "Value": "jellyfin" },
        { "Key": "username", "Value": "jellyfin" },
        { "Key": "password", "Value": "your_secure_password" },
        { "Key": "pooling", "Value": "true" },
        { "Key": "command-timeout", "Value": "30" },
        { "Key": "connection-timeout", "Value": "15" }
      ]
    }
  }
}

Database Setup

Before using this provider, ensure PostgreSQL is installed and create the database:

CREATE DATABASE jellyfin;
CREATE USER jellyfin WITH PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE jellyfin TO jellyfin;

Creating Migrations

To create a new migration:

cd src/Jellyfin.Database/Jellyfin.Database.Providers.Postgres
dotnet ef migrations add YourMigrationName --context JellyfinDbContext

Applying Migrations

Migrations will be applied automatically when Jellyfin starts. You can also apply them manually:

dotnet ef database update --context JellyfinDbContext

Backup and Restore

Unlike SQLite, PostgreSQL backups should be managed externally using PostgreSQL tools:

# Backup
pg_dump -U jellyfin -h localhost jellyfin > jellyfin_backup.sql

# Restore
psql -U jellyfin -h localhost jellyfin < jellyfin_backup.sql

Configuration Options

Key Default Description
host localhost PostgreSQL server hostname
port 5432 PostgreSQL server port
database jellyfin Database name
username jellyfin Database username
password (empty) Database password
pooling true Enable connection pooling
command-timeout 30 Command timeout in seconds
connection-timeout 15 Connection timeout in seconds
EnableSensitiveDataLogging false Enable sensitive data logging (for debugging)

Performance Tuning

For better performance, consider:

  1. Indexes: The provider will create necessary indexes through migrations
  2. Connection Pooling: Enabled by default
  3. Vacuum: Scheduled optimization runs VACUUM ANALYZE periodically
  4. PostgreSQL Configuration: Adjust shared_buffers, effective_cache_size, etc. in postgresql.conf

Notes

  • Migrations from SQLite are not automatically handled. You'll need to export data from SQLite and import into PostgreSQL manually.
  • The provider uses UTC timestamps throughout for consistency.
  • Transaction isolation level and other PostgreSQL-specific features can be configured through Npgsql connection string parameters.