# 🚀 Quick Reference: Publish Jellyfin with SQL Files

## One Command Solution

```powershell
.\publish-with-sql.ps1
```

That's it! Everything is handled automatically.

---

## What Gets Published

```
publish/
├── jellyfin.exe
├── ... (all DLLs and files)
└── sql/                                    ← SQL files included!
    ├── all_performance_indexes.sql         ← Main performance script
    ├── add_base_performance_indexes.sql
    ├── diagnostics.sql
    └── schema_init/
        └── 10_create_supplementary_indexes.sql
```

---

## Verify After Publish

```powershell
# Check if SQL files are present
Test-Path "Jellyfin.Server\bin\Release\net11.0\publish\sql\all_performance_indexes.sql"
# Returns: True ✅

# List all SQL files
ls "Jellyfin.Server\bin\Release\net11.0\publish\sql" -Recurse
```

---

## Manual Method (If Needed)

```powershell
# 1. Publish
dotnet publish Jellyfin.Server\Jellyfin.Server.csproj -c Release

# 2. Copy SQL files
.\copy-sql-files.ps1
```

---

## What Happens on Startup

```
Jellyfin starts
    ↓
Checks if performance indexes exist
    ↓
Missing? → Loads sql/all_performance_indexes.sql
    ↓
Creates 23 performance indexes automatically
    ↓
✅ Database optimized!
```

---

## Logs You'll See

```
[INF] Found 0/9 base performance indexes. Applying SQL script...
[INF] Executing performance indexes script: .../sql/all_performance_indexes.sql
[INF] Performance indexes created successfully. Database is now fully optimized.
```

---

## Files Created for You

1. **`publish-with-sql.ps1`** - Automated publish + copy script ⭐
2. **`copy-sql-files.ps1`** - Manual copy script
3. **`Jellyfin.Server/sql/`** - SQL files directory

---

## Troubleshooting

### SQL files not in publish output?
```powershell
# Run the publish script
.\publish-with-sql.ps1
```

### Already published without SQL files?
```powershell
# Just copy them
.\copy-sql-files.ps1
```

### Need to verify?
```powershell
# Check the files
dir "Jellyfin.Server\bin\Release\net11.0\publish\sql"
```

---

## Quick Test

```powershell
# 1. Publish
.\publish-with-sql.ps1

# 2. Run
cd Jellyfin.Server\bin\Release\net11.0\publish
.\jellyfin.exe

# 3. Check logs - should see "Performance indexes created successfully"
```

---

**That's all you need to know!** 🎉

Use `.\publish-with-sql.ps1` and you're done!
