- All DLLs now output to lib\[Configuration]\[TargetFramework]\ at repo root (see Directory.Build.props) - .gitignore updated to exclude /lib/ - On first run, startup.json is auto-generated with OS-appropriate default paths (Windows, Linux, macOS, or portable) - Removes null/example config; generated config is immediately usable and clearly documented - Extensive new documentation: build output, startup.json logic, visual guides, and code proofs - Publish profile now deletes existing files for clean deploys - No breaking changes: existing startup.json files are preserved - Improves first-run UX, deployment, and cross-platform consistency
6.9 KiB
Summary: Multi-Database Configuration with Presets
✅ Feature Implemented!
Yes! The database.xml configuration file now includes preset configurations for both SQLite and PostgreSQL, making it easy to switch between database providers.
🎯 What Was Added
1. Preset Configurations in database.xml
The configuration file now includes a <PresetConfigurations> section with example configurations for:
- SQLite (default) - Single-file database
- PostgreSQL-Local - PostgreSQL on localhost
2. New Configuration Classes
PresetDatabaseConfiguration.cs - Stores template database configurations
public class PresetDatabaseConfiguration
{
public string? DatabaseType { get; set; }
public CustomDatabaseOptions? CustomProviderOptions { get; set; }
public DatabaseLockingBehaviorTypes LockingBehavior { get; set; }
public string? Description { get; set; }
}
Updated DatabaseConfigurationOptions.cs - Added PresetConfigurations property
public Dictionary<string, PresetDatabaseConfiguration>? PresetConfigurations { get; set; }
📄 Configuration File Structure
The database.xml file now looks like this:
<DatabaseConfigurationOptions>
<!-- ACTIVE CONFIGURATION -->
<DatabaseType>Jellyfin-SQLite</DatabaseType>
<LockingBehavior>NoLock</LockingBehavior>
<!-- POSTGRESQL OPTIONS (when needed) -->
<CustomProviderOptions>
<!-- PostgreSQL settings -->
</CustomProviderOptions>
<!-- PRESET CONFIGURATIONS (Templates) -->
<PresetConfigurations>
<PresetConfiguration>
<key>SQLite</key>
<value>
<DatabaseType>Jellyfin-SQLite</DatabaseType>
<Description>Default SQLite database</Description>
</value>
</PresetConfiguration>
<PresetConfiguration>
<key>PostgreSQL-Local</key>
<value>
<DatabaseType>Jellyfin-PostgreSQL</DatabaseType>
<Description>PostgreSQL on localhost</Description>
</value>
</PresetConfiguration>
</PresetConfigurations>
</DatabaseConfigurationOptions>
🔄 How to Switch Databases
Step 1: Stop Jellyfin
sudo systemctl stop jellyfin
Step 2: Edit database.xml
To use SQLite:
<DatabaseType>Jellyfin-SQLite</DatabaseType>
<!-- Remove or comment out CustomProviderOptions -->
To use PostgreSQL:
<DatabaseType>Jellyfin-PostgreSQL</DatabaseType>
<CustomProviderOptions>
<PluginName>Jellyfin.Database.Providers.Postgres</PluginName>
<PluginAssembly>Jellyfin.Database.Providers.Postgres.dll</PluginAssembly>
<ConnectionString></ConnectionString>
<Options>
<CustomDatabaseOption>
<Key>host</Key>
<Value>localhost</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>
Step 3: Start Jellyfin
sudo systemctl start jellyfin
📍 Configuration File Location
- Linux:
/etc/jellyfin/database.xmlor~/.config/jellyfin/database.xml - Windows:
%ProgramData%\Jellyfin\config\database.xml - Docker:
/config/database.xml(in your config volume)
💡 Key Benefits
- ✅ No need to remember syntax - Examples are right in the file
- ✅ Quick reference - See all available options at a glance
- ✅ Easy switching - Just change one line and add credentials
- ✅ Self-documenting - Descriptions explain what each preset does
- ✅ No separate documentation needed - Everything in one place
🗂️ Files Modified
Created:
-
src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/PresetDatabaseConfiguration.cs
- New class to store preset configurations
-
database.xml.example
- Complete example configuration file with comments
-
DATABASE_CONFIGURATION_GUIDE.md
- Comprehensive guide for database configuration
Modified:
-
src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs
- Added PresetConfigurations property
-
Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs
- Added default preset creation on first startup
📋 Example Presets Included
SQLite Preset
<PresetConfiguration>
<key>SQLite</key>
<value>
<DatabaseType>Jellyfin-SQLite</DatabaseType>
<LockingBehavior>NoLock</LockingBehavior>
<Description>Default SQLite database configuration. Database stored in data directory.</Description>
</value>
</PresetConfiguration>
PostgreSQL Preset
<PresetConfiguration>
<key>PostgreSQL-Local</key>
<value>
<DatabaseType>Jellyfin-PostgreSQL</DatabaseType>
<LockingBehavior>NoLock</LockingBehavior>
<Description>PostgreSQL database on localhost. Update Options with your database credentials.</Description>
</value>
</PresetConfiguration>
🚀 Usage Workflow
- First Startup: database.xml is created with SQLite active and presets included
- View Presets: Open database.xml to see available configurations
- Switch Database:
- Change
<DatabaseType>to desired provider - Add/update
<CustomProviderOptions>if using PostgreSQL - Restart Jellyfin
- Change
- Done: Jellyfin now uses the new database
🎨 Advanced Customization
You can add your own presets to the configuration file:
<PresetConfiguration>
<key>PostgreSQL-Production</key>
<value>
<DatabaseType>Jellyfin-PostgreSQL</DatabaseType>
<LockingBehavior>Optimistic</LockingBehavior>
<Description>PostgreSQL production server with optimistic locking</Description>
</value>
</PresetConfiguration>
⚠️ Important Notes
- Presets are templates only - They don't activate automatically
- Copy settings to active configuration to use them
- Stop Jellyfin before editing database.xml
- Protect the file - It may contain passwords
- Backup before changing database types
🔒 Security
# Protect database.xml
chmod 600 /etc/jellyfin/database.xml
chown jellyfin:jellyfin /etc/jellyfin/database.xml
🏗️ Build Status
✅ Build Successful
✅ No Breaking Changes
✅ Backward Compatible
✅ Comprehensive Documentation
📚 Documentation
Created comprehensive guides:
- DATABASE_CONFIGURATION_GUIDE.md - Complete configuration reference
- database.xml.example - Annotated example file
- This summary - Quick reference
Your database.xml file now includes preset configurations for easy switching between SQLite and PostgreSQL! 🎉
Just edit one line (<DatabaseType>) and optionally add PostgreSQL credentials to switch databases. No need to remember complex configuration syntax - it's all right there in the file!