Centralize build output and generate OS-specific startup.json
- 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
This commit is contained in:
@@ -0,0 +1,240 @@
|
||||
# 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
|
||||
|
||||
```csharp
|
||||
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
|
||||
|
||||
```csharp
|
||||
public Dictionary<string, PresetDatabaseConfiguration>? PresetConfigurations { get; set; }
|
||||
```
|
||||
|
||||
## 📄 Configuration File Structure
|
||||
|
||||
The `database.xml` file now looks like this:
|
||||
|
||||
```xml
|
||||
<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
|
||||
```bash
|
||||
sudo systemctl stop jellyfin
|
||||
```
|
||||
|
||||
### Step 2: Edit database.xml
|
||||
|
||||
**To use SQLite:**
|
||||
```xml
|
||||
<DatabaseType>Jellyfin-SQLite</DatabaseType>
|
||||
<!-- Remove or comment out CustomProviderOptions -->
|
||||
```
|
||||
|
||||
**To use PostgreSQL:**
|
||||
```xml
|
||||
<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
|
||||
```bash
|
||||
sudo systemctl start jellyfin
|
||||
```
|
||||
|
||||
## 📍 Configuration File Location
|
||||
|
||||
- **Linux**: `/etc/jellyfin/database.xml` or `~/.config/jellyfin/database.xml`
|
||||
- **Windows**: `%ProgramData%\Jellyfin\config\database.xml`
|
||||
- **Docker**: `/config/database.xml` (in your config volume)
|
||||
|
||||
## 💡 Key Benefits
|
||||
|
||||
1. **✅ No need to remember syntax** - Examples are right in the file
|
||||
2. **✅ Quick reference** - See all available options at a glance
|
||||
3. **✅ Easy switching** - Just change one line and add credentials
|
||||
4. **✅ Self-documenting** - Descriptions explain what each preset does
|
||||
5. **✅ No separate documentation needed** - Everything in one place
|
||||
|
||||
## 🗂️ Files Modified
|
||||
|
||||
### Created:
|
||||
1. **src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/PresetDatabaseConfiguration.cs**
|
||||
- New class to store preset configurations
|
||||
|
||||
2. **database.xml.example**
|
||||
- Complete example configuration file with comments
|
||||
|
||||
3. **DATABASE_CONFIGURATION_GUIDE.md**
|
||||
- Comprehensive guide for database configuration
|
||||
|
||||
### Modified:
|
||||
1. **src/Jellyfin.Database/Jellyfin.Database.Implementations/DbConfiguration/DatabaseConfigurationOptions.cs**
|
||||
- Added PresetConfigurations property
|
||||
|
||||
2. **Jellyfin.Server.Implementations/Extensions/ServiceCollectionExtensions.cs**
|
||||
- Added default preset creation on first startup
|
||||
|
||||
## 📋 Example Presets Included
|
||||
|
||||
### SQLite Preset
|
||||
```xml
|
||||
<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
|
||||
```xml
|
||||
<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
|
||||
|
||||
1. **First Startup**: database.xml is created with SQLite active and presets included
|
||||
2. **View Presets**: Open database.xml to see available configurations
|
||||
3. **Switch Database**:
|
||||
- Change `<DatabaseType>` to desired provider
|
||||
- Add/update `<CustomProviderOptions>` if using PostgreSQL
|
||||
- Restart Jellyfin
|
||||
4. **Done**: Jellyfin now uses the new database
|
||||
|
||||
## 🎨 Advanced Customization
|
||||
|
||||
You can add your own presets to the configuration file:
|
||||
|
||||
```xml
|
||||
<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
|
||||
|
||||
1. **Presets are templates only** - They don't activate automatically
|
||||
2. **Copy settings to active configuration** to use them
|
||||
3. **Stop Jellyfin before editing** database.xml
|
||||
4. **Protect the file** - It may contain passwords
|
||||
5. **Backup before changing** database types
|
||||
|
||||
## 🔒 Security
|
||||
|
||||
```bash
|
||||
# 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:
|
||||
1. **DATABASE_CONFIGURATION_GUIDE.md** - Complete configuration reference
|
||||
2. **database.xml.example** - Annotated example file
|
||||
3. **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!
|
||||
Reference in New Issue
Block a user