Move scripts to scripts directory and remove odcs no longer needed.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
@echo off
|
||||
REM Quick script to add ALL performance indexes (base + supplementary)
|
||||
|
||||
echo ========================================
|
||||
echo Add ALL Performance Indexes
|
||||
echo ========================================
|
||||
echo.
|
||||
echo This will create:
|
||||
echo - 18 base performance indexes
|
||||
echo - 5 supplementary indexes
|
||||
echo Total: 23 indexes
|
||||
echo.
|
||||
echo NOTE: This uses the database configured in db-config.ps1
|
||||
echo Current default: jellyfin_testsdata
|
||||
echo.
|
||||
echo This may take 10-30 minutes...
|
||||
echo.
|
||||
|
||||
REM Use PowerShell to load config and run
|
||||
powershell -Command ". .\db-config.ps1; & $PSQL_PATH -U $DB_USER -d $DB_NAME -f sql\all_performance_indexes.sql"
|
||||
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Success! All 23 indexes added.
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Performance improvement: 70-90 percent faster!
|
||||
echo.
|
||||
echo Next: Restart Jellyfin
|
||||
echo.
|
||||
) else (
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Failed to add indexes
|
||||
echo ========================================
|
||||
echo.
|
||||
)
|
||||
|
||||
pause
|
||||
@@ -0,0 +1,37 @@
|
||||
@echo off
|
||||
REM Add missing base performance indexes to Jellyfin database
|
||||
|
||||
echo ========================================
|
||||
echo Add Base Performance Indexes
|
||||
echo ========================================
|
||||
echo.
|
||||
echo These indexes were missing from InitialCreate
|
||||
echo Adding 18 essential performance indexes...
|
||||
echo.
|
||||
|
||||
"C:\Program Files\PostgreSQL\18\bin\psql.exe" -U jellyfin -d jellyfin -f sql\add_base_performance_indexes.sql
|
||||
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Success! Base indexes added.
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Indexes created:
|
||||
echo - 9 on BaseItems
|
||||
echo - 2 on BaseItemProviders
|
||||
echo - 2 on MediaStreamInfos
|
||||
echo - 2 on PeopleBaseItemMap
|
||||
echo - 3 on UserData
|
||||
echo.
|
||||
echo Next: Restart Jellyfin
|
||||
echo.
|
||||
) else (
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Failed to add indexes
|
||||
echo ========================================
|
||||
echo.
|
||||
)
|
||||
|
||||
pause
|
||||
@@ -0,0 +1,38 @@
|
||||
@echo off
|
||||
REM Quick script to add supplementary indexes to jellyfin_testsdata
|
||||
|
||||
echo ========================================
|
||||
echo Add Supplementary Indexes
|
||||
echo ========================================
|
||||
echo.
|
||||
|
||||
echo Connecting to jellyfin_testsdata database...
|
||||
echo.
|
||||
|
||||
REM Apply the indexes
|
||||
"C:\Program Files\PostgreSQL\18\bin\psql.exe" -U jellyfin -d jellyfin -f sql\schema_init\10_create_supplementary_indexes.sql
|
||||
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Success! Indexes added.
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Next steps:
|
||||
echo 1. Restart Jellyfin
|
||||
echo 2. Monitor performance
|
||||
echo.
|
||||
) else (
|
||||
echo.
|
||||
echo ========================================
|
||||
echo Failed to add indexes
|
||||
echo ========================================
|
||||
echo.
|
||||
echo Troubleshooting:
|
||||
echo - Ensure PostgreSQL is running
|
||||
echo - Check database name is correct
|
||||
echo - Verify credentials
|
||||
echo.
|
||||
)
|
||||
|
||||
pause
|
||||
@@ -0,0 +1,20 @@
|
||||
# Add Supplementary Indexes - Quick Command
|
||||
|
||||
Write-Host "Connecting to jellyfin_testsdata and adding supplementary indexes..." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Quick and simple - just run the SQL script
|
||||
psql -U jellyfin -d jellyfin_testsdata -f sql\schema_init\10_create_supplementary_indexes.sql
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host ""
|
||||
Write-Host "✓ Success! Supplementary indexes added." -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "Next: Restart Jellyfin to see performance improvements" -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host ""
|
||||
Write-Host "❌ Failed. Check that:" -ForegroundColor Red
|
||||
Write-Host " - PostgreSQL is running" -ForegroundColor Gray
|
||||
Write-Host " - Database 'jellyfin_testsdata' exists" -ForegroundColor Gray
|
||||
Write-Host " - You have the correct password" -ForegroundColor Gray
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
# Apply ItemValues Optimized Indexes
|
||||
# These indexes target the critical ItemValues table performance issue
|
||||
# Note: Creates SQL file first, then executes it to avoid CONCURRENTLY transaction issues
|
||||
|
||||
. .\db-config.ps1
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "Creating Optimized ItemValues Indexes" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "Target: library.ItemValues table" -ForegroundColor Yellow
|
||||
Write-Host "Problem: 1.3 BILLION rows being scanned sequentially" -ForegroundColor Red
|
||||
Write-Host "Solution: 3 targeted indexes" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "This may take 10-30 minutes..." -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
# Create temporary SQL file (CONCURRENTLY requires running outside transaction)
|
||||
$tempSqlFile = "temp_itemvalues_indexes.sql"
|
||||
|
||||
$sqlContent = @"
|
||||
-- Optimized indexes for ItemValues table
|
||||
-- Fixes the 1.3 billion row sequential scan issue
|
||||
|
||||
-- Index 1: CleanValue lookups (for genre/tag searches)
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_itemvalues_cleanvalue
|
||||
ON library."ItemValues" ("CleanValue")
|
||||
WHERE "CleanValue" IS NOT NULL;
|
||||
|
||||
-- Index 2: Value lookups (for direct value searches)
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_itemvalues_value
|
||||
ON library."ItemValues" ("Value")
|
||||
WHERE "Value" IS NOT NULL;
|
||||
|
||||
-- Index 3: ItemValueId + CleanValue for joins (ItemValuesMap to ItemValues)
|
||||
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_itemvalues_id_cleanvalue
|
||||
ON library."ItemValues" ("ItemValueId", "CleanValue");
|
||||
"@
|
||||
|
||||
# Write SQL to temp file WITHOUT BOM (UTF8 without BOM)
|
||||
[System.IO.File]::WriteAllText((Join-Path $PWD $tempSqlFile), $sqlContent, (New-Object System.Text.UTF8Encoding $false))
|
||||
|
||||
Write-Host "Executing index creation script..." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Execute the SQL file (allows CONCURRENTLY to work)
|
||||
& $PSQL_PATH -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -f $tempSqlFile
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host ""
|
||||
Write-Host "[OK] All 3 indexes created successfully!" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host ""
|
||||
Write-Host "[FAILED] Some indexes may have failed to create" -ForegroundColor Red
|
||||
Write-Host "Check the output above for details" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Clean up temp file
|
||||
Remove-Item $tempSqlFile -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "Index Creation Complete!" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Verify indexes were created
|
||||
Write-Host "Verifying indexes..." -ForegroundColor Yellow
|
||||
$queryVerify = "SELECT indexrelname as indexname, pg_size_pretty(pg_relation_size(indexrelid)) as size FROM pg_stat_user_indexes WHERE schemaname = 'library' AND relname = 'ItemValues' AND indexrelname LIKE 'idx_itemvalues_%' ORDER BY indexrelname;"
|
||||
& $PSQL_PATH -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c $queryVerify
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Next steps:" -ForegroundColor Cyan
|
||||
Write-Host "1. Use Jellyfin normally - browse, filter by genre and tags" -ForegroundColor Gray
|
||||
Write-Host "2. Wait 1 week" -ForegroundColor Gray
|
||||
Write-Host "3. Run diagnostics again using db-quick.ps1" -ForegroundColor Gray
|
||||
Write-Host "4. Check improvement in ItemValues sequential scans" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
Write-Host "Expected improvement: 70-90 percent faster genre and tag queries!" -ForegroundColor Green
|
||||
@@ -0,0 +1,162 @@
|
||||
# Build Jellyfin Installer
|
||||
# This script builds the Jellyfin installer using Inno Setup
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$Version = "11.0.0-PostgreSQL-PREVIEW",
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[ValidateSet("Release", "Debug")]
|
||||
[string]$Configuration = "Release",
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$SkipBuild
|
||||
)
|
||||
|
||||
Write-Host "`n╔══════════════════════════════════════════════════════════╗" -ForegroundColor Cyan
|
||||
Write-Host "║ Jellyfin PostgreSQL Installer Builder ║" -ForegroundColor Cyan
|
||||
Write-Host "╚══════════════════════════════════════════════════════════╝`n" -ForegroundColor Cyan
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ScriptDir = $PSScriptRoot
|
||||
$SolutionRoot = "E:\Projects\pgsql-jellyfin"
|
||||
$InnoSetupPath = "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe"
|
||||
|
||||
# Check prerequisites
|
||||
Write-Host "Checking prerequisites..." -ForegroundColor Yellow
|
||||
|
||||
# Check if Inno Setup is installed
|
||||
if (-not (Test-Path $InnoSetupPath)) {
|
||||
Write-Host "❌ Inno Setup 6 not found!" -ForegroundColor Red
|
||||
Write-Host "Please install it from: https://jrsoftware.org/isinfo.php" -ForegroundColor Yellow
|
||||
Write-Host "Or run: winget install JRSoftware.InnoSetup" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
Write-Host "✅ Inno Setup found" -ForegroundColor Green
|
||||
|
||||
# Check if lib folder exists
|
||||
if (-not (Test-Path "$SolutionRoot\lib\$Configuration\net11.0")) {
|
||||
if ($SkipBuild) {
|
||||
Write-Host "❌ Build folder not found: $SolutionRoot\lib\$Configuration\net11.0" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "⚠️ Build folder not found, building solution first..." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Build the solution if needed
|
||||
if (-not $SkipBuild) {
|
||||
Write-Host "`nBuilding Jellyfin solution..." -ForegroundColor Cyan
|
||||
Push-Location $SolutionRoot
|
||||
|
||||
try {
|
||||
# Clean previous build
|
||||
Write-Host "Cleaning previous build..." -ForegroundColor Gray
|
||||
dotnet clean --configuration $Configuration | Out-Null
|
||||
|
||||
# Build solution
|
||||
Write-Host "Building $Configuration configuration..." -ForegroundColor Gray
|
||||
$buildOutput = dotnet build Jellyfin.Server --configuration $Configuration 2>&1
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ Build failed!" -ForegroundColor Red
|
||||
Write-Host $buildOutput
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "✅ Build successful" -ForegroundColor Green
|
||||
|
||||
# Count DLLs
|
||||
$dllCount = (Get-ChildItem "$SolutionRoot\lib\$Configuration\net11.0" -Filter "*.dll" -Recurse).Count
|
||||
Write-Host "📊 Built $dllCount DLL files" -ForegroundColor Gray
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
|
||||
# Check if installer script exists
|
||||
$InnoScriptPath = "$SolutionRoot\jellyfin-setup.iss"
|
||||
if (-not (Test-Path $InnoScriptPath)) {
|
||||
Write-Host "❌ Installer script not found: $InnoScriptPath" -ForegroundColor Red
|
||||
Write-Host "Please ensure jellyfin-setup.iss is in the solution root" -ForegroundColor Yellow
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check for icon file (optional)
|
||||
$IconPath = "$SolutionRoot\jellyfin.ico"
|
||||
if (-not (Test-Path $IconPath)) {
|
||||
Write-Host "⚠️ Icon file not found: $IconPath" -ForegroundColor Yellow
|
||||
Write-Host "The installer will use the default Inno Setup icon" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
# Update version in script if needed
|
||||
Write-Host "`nPreparing installer script..." -ForegroundColor Cyan
|
||||
$scriptContent = Get-Content $InnoScriptPath -Raw
|
||||
$scriptContent = $scriptContent -replace 'AppVersion=[\d\.]+', "AppVersion=$Version"
|
||||
$scriptContent = $scriptContent -replace 'OutputBaseFilename=JellyfinSetup-PostgreSQL-[\d\.]+', "OutputBaseFilename=JellyfinSetup-PostgreSQL-$Version"
|
||||
Set-Content $InnoScriptPath $scriptContent -NoNewline
|
||||
Write-Host "✅ Version updated to $Version" -ForegroundColor Green
|
||||
|
||||
# Create output directory
|
||||
$OutputDir = "$SolutionRoot\installer-output"
|
||||
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null
|
||||
|
||||
# Build the installer
|
||||
Write-Host "`nBuilding installer..." -ForegroundColor Cyan
|
||||
Write-Host "Script: $InnoScriptPath" -ForegroundColor Gray
|
||||
Write-Host "Output: $OutputDir" -ForegroundColor Gray
|
||||
|
||||
Push-Location $SolutionRoot
|
||||
|
||||
try {
|
||||
$compileOutput = & $InnoSetupPath $InnoScriptPath 2>&1
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ Installer build failed!" -ForegroundColor Red
|
||||
Write-Host $compileOutput
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "✅ Installer built successfully!" -ForegroundColor Green
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
# Find the installer file
|
||||
$installerFile = Get-ChildItem $OutputDir -Filter "JellyfinSetup-PostgreSQL-*.exe" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||
|
||||
if ($installerFile) {
|
||||
$fileSize = [math]::Round($installerFile.Length / 1MB, 2)
|
||||
|
||||
Write-Host "`n╔══════════════════════════════════════════════════════════╗" -ForegroundColor Green
|
||||
Write-Host "║ Installer Build Complete! ✅ ║" -ForegroundColor Green
|
||||
Write-Host "╚══════════════════════════════════════════════════════════╝`n" -ForegroundColor Green
|
||||
|
||||
Write-Host "📦 Installer Details:" -ForegroundColor Cyan
|
||||
Write-Host " File: $($installerFile.Name)" -ForegroundColor White
|
||||
Write-Host " Path: $($installerFile.FullName)" -ForegroundColor White
|
||||
Write-Host " Size: $fileSize MB" -ForegroundColor White
|
||||
Write-Host " Date: $($installerFile.LastWriteTime)" -ForegroundColor White
|
||||
|
||||
Write-Host "`n📋 Next Steps:" -ForegroundColor Cyan
|
||||
Write-Host " 1. Test the installer on a clean Windows system" -ForegroundColor Gray
|
||||
Write-Host " 2. Sign the installer (optional): signtool sign /f cert.pfx installer.exe" -ForegroundColor Gray
|
||||
Write-Host " 3. Upload to GitHub releases or your distribution server" -ForegroundColor Gray
|
||||
|
||||
Write-Host "`n🧪 Test Commands:" -ForegroundColor Cyan
|
||||
Write-Host " # Silent install" -ForegroundColor Gray
|
||||
Write-Host " $($installerFile.FullName) /VERYSILENT /LOG=install.log" -ForegroundColor DarkGray
|
||||
Write-Host " # Normal install" -ForegroundColor Gray
|
||||
Write-Host " $($installerFile.FullName)" -ForegroundColor DarkGray
|
||||
|
||||
# Open output folder
|
||||
Write-Host "`nOpening output folder..." -ForegroundColor Cyan
|
||||
Start-Process $OutputDir
|
||||
}
|
||||
else {
|
||||
Write-Host "❌ Installer file not found in output directory!" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "`n✅ All done!`n" -ForegroundColor Green
|
||||
@@ -0,0 +1,22 @@
|
||||
# copy-sql-files.ps1
|
||||
# Run this after publish to copy SQL files
|
||||
|
||||
param(
|
||||
[string]$PublishDir = "Jellyfin.Server\bin\Release\net11.0\publish"
|
||||
)
|
||||
|
||||
Write-Host "Copying SQL files to $PublishDir..." -ForegroundColor Cyan
|
||||
|
||||
# Create sql directory
|
||||
New-Item -ItemType Directory -Path "$PublishDir\sql" -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path "$PublishDir\sql\schema_init" -Force | Out-Null
|
||||
|
||||
# Copy SQL files
|
||||
Copy-Item "Jellyfin.Server\sql\*.sql" "$PublishDir\sql\" -Force
|
||||
Copy-Item "Jellyfin.Server\sql\schema_init\*.sql" "$PublishDir\sql\schema_init\" -Force -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "✓ SQL files copied successfully!" -ForegroundColor Green
|
||||
|
||||
# List copied files
|
||||
Write-Host "`nCopied files:" -ForegroundColor Yellow
|
||||
Get-ChildItem "$PublishDir\sql" -Recurse -File | Select-Object FullName
|
||||
@@ -0,0 +1,57 @@
|
||||
# Database Configuration
|
||||
# Edit this file to change which database commands run against
|
||||
|
||||
# Database connection settings
|
||||
$PSQL_PATH = "C:\Program Files\PostgreSQL\18\bin\psql.exe"
|
||||
$DB_USER = "postgres"
|
||||
$DB_NAME = "jellyfin_testdata" # ← Change this to switch databases
|
||||
$DB_HOST = "192.168.129.248"
|
||||
$DB_PORT = "5432"
|
||||
|
||||
# Export for use in other scripts
|
||||
$global:PSQL_PATH = $PSQL_PATH
|
||||
$global:DB_USER = $DB_USER
|
||||
$global:DB_NAME = $DB_NAME
|
||||
$global:DB_HOST = $DB_HOST
|
||||
$global:DB_PORT = $DB_PORT
|
||||
|
||||
# Helper function to run psql commands
|
||||
function Invoke-PSQL {
|
||||
param(
|
||||
[string]$Query,
|
||||
[string]$File,
|
||||
[string]$OutputFile
|
||||
)
|
||||
|
||||
$baseCmd = "& `"$PSQL_PATH`" -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME"
|
||||
|
||||
if ($File) {
|
||||
$cmd = "$baseCmd -f `"$File`""
|
||||
} elseif ($Query) {
|
||||
$cmd = "$baseCmd -c `"$Query`""
|
||||
} else {
|
||||
Write-Error "Must provide either -Query or -File parameter"
|
||||
return
|
||||
}
|
||||
|
||||
if ($OutputFile) {
|
||||
$cmd += " > `"$OutputFile`""
|
||||
}
|
||||
|
||||
Write-Host "Connecting to: $DB_NAME@$DB_HOST as $DB_USER" -ForegroundColor Cyan
|
||||
Invoke-Expression $cmd
|
||||
}
|
||||
|
||||
# Display current configuration
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "Database Configuration Loaded" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "Database: $DB_NAME" -ForegroundColor Yellow
|
||||
Write-Host "User: $DB_USER" -ForegroundColor Yellow
|
||||
Write-Host "Host: $DB_HOST" -ForegroundColor Yellow
|
||||
Write-Host "Port: $DB_PORT" -ForegroundColor Yellow
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "To change database, edit: db-config.ps1" -ForegroundColor Gray
|
||||
Write-Host "Then run: . .\db-config.ps1" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
@@ -0,0 +1,66 @@
|
||||
# Quick Database Command Runner
|
||||
# Uses settings from db-config.ps1
|
||||
|
||||
# Load configuration
|
||||
. .\db-config.ps1
|
||||
|
||||
Write-Host "Quick Database Commands" -ForegroundColor Cyan
|
||||
Write-Host "Using database: $DB_NAME" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
# Show menu
|
||||
Write-Host "Choose an option:" -ForegroundColor Green
|
||||
Write-Host "1. Run diagnostics (sql\diagnostics.sql)"
|
||||
Write-Host "2. Check index usage"
|
||||
Write-Host "3. Check if performance indexes exist"
|
||||
Write-Host "4. Run all performance indexes script"
|
||||
Write-Host "5. Custom query"
|
||||
Write-Host "6. Change database"
|
||||
Write-Host "7. Exit"
|
||||
Write-Host ""
|
||||
|
||||
$choice = Read-Host "Enter choice (1-7)"
|
||||
|
||||
switch ($choice) {
|
||||
"1" {
|
||||
Write-Host "Running diagnostics..." -ForegroundColor Yellow
|
||||
Invoke-PSQL -File "sql\diagnostics.sql" -OutputFile "diagnostics_$(Get-Date -Format 'yyyy-MM-dd_HHmmss').txt"
|
||||
Write-Host "✓ Results saved to diagnostics_*.txt" -ForegroundColor Green
|
||||
}
|
||||
"2" {
|
||||
Write-Host "Checking index usage..." -ForegroundColor Yellow
|
||||
$query = "SELECT indexname, idx_scan, idx_tup_read, idx_tup_fetch FROM pg_stat_user_indexes WHERE schemaname = 'library' AND indexname LIKE 'idx_%' ORDER BY idx_scan DESC;"
|
||||
Invoke-PSQL -Query $query
|
||||
}
|
||||
"3" {
|
||||
Write-Host "Checking performance indexes..." -ForegroundColor Yellow
|
||||
$query = "SELECT COUNT(*) as perf_index_count FROM pg_indexes WHERE schemaname = 'library' AND indexname IN ('baseitems_communityrating_idx', 'baseitems_datecreated_idx', 'baseitems_datemodified_idx', 'baseitems_parentid_idx', 'baseitems_premieredate_idx', 'baseitems_productionyear_idx', 'baseitems_seriespresentationuniquekey_idx', 'baseitems_sortname_idx', 'baseitems_topparentid_idx');"
|
||||
Invoke-PSQL -Query $query
|
||||
}
|
||||
"4" {
|
||||
Write-Host "Running all performance indexes script..." -ForegroundColor Yellow
|
||||
Invoke-PSQL -File "sql\all_performance_indexes.sql"
|
||||
Write-Host "✓ Script complete" -ForegroundColor Green
|
||||
}
|
||||
"5" {
|
||||
$query = Read-Host "Enter SQL query"
|
||||
Invoke-PSQL -Query $query
|
||||
}
|
||||
"6" {
|
||||
Write-Host ""
|
||||
Write-Host "Current database: $DB_NAME" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Write-Host "To change database:" -ForegroundColor Cyan
|
||||
Write-Host "1. Edit db-config.ps1" -ForegroundColor Gray
|
||||
Write-Host "2. Change the line: `$DB_NAME = `"jellyfin_testsdata`"" -ForegroundColor Gray
|
||||
Write-Host "3. Save and run: . .\db-config.ps1" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
}
|
||||
"7" {
|
||||
Write-Host "Goodbye!" -ForegroundColor Cyan
|
||||
exit
|
||||
}
|
||||
default {
|
||||
Write-Host "Invalid choice" -ForegroundColor Red
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
# publish-with-sql.ps1
|
||||
# Publishes Jellyfin and ensures SQL files are included
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "Publishing Jellyfin with SQL files" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
Write-Host "Step 1: Publishing Jellyfin..." -ForegroundColor Yellow
|
||||
dotnet publish Jellyfin.Server\Jellyfin.Server.csproj -c Release -o Jellyfin.Server\bin\Release\net11.0\publish
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "❌ Publish failed" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "✓ Publish successful" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
Write-Host "Step 2: Copying SQL files..." -ForegroundColor Yellow
|
||||
|
||||
$publishDir = "Jellyfin.Server\bin\Release\net11.0\publish"
|
||||
|
||||
# Create sql directory structure
|
||||
New-Item -ItemType Directory -Path "$publishDir\sql" -Force | Out-Null
|
||||
New-Item -ItemType Directory -Path "$publishDir\sql\schema_init" -Force | Out-Null
|
||||
|
||||
# Copy SQL files
|
||||
try {
|
||||
Copy-Item "Jellyfin.Server\sql\*.sql" "$publishDir\sql\" -Force -ErrorAction Stop
|
||||
$mainFileCount = (Get-ChildItem "$publishDir\sql\*.sql").Count
|
||||
Write-Host " ✓ Copied $mainFileCount main SQL files" -ForegroundColor Green
|
||||
|
||||
Copy-Item "Jellyfin.Server\sql\schema_init\*.sql" "$publishDir\sql\schema_init\" -Force -ErrorAction SilentlyContinue
|
||||
$initFileCount = (Get-ChildItem "$publishDir\sql\schema_init\*.sql" -ErrorAction SilentlyContinue).Count
|
||||
Write-Host " ✓ Copied $initFileCount schema_init SQL files" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "❌ Failed to copy SQL files: $_" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host "✓ Publish Complete!" -ForegroundColor Green
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "Output directory: $publishDir" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Write-Host "SQL files:" -ForegroundColor Yellow
|
||||
Get-ChildItem "$publishDir\sql" -Recurse -File | ForEach-Object {
|
||||
Write-Host " - $($_.FullName.Replace($PWD.Path + '\', ''))" -ForegroundColor Gray
|
||||
}
|
||||
Write-Host ""
|
||||
Write-Host "Next: Run jellyfin.exe from the publish directory" -ForegroundColor Cyan
|
||||
@@ -0,0 +1,28 @@
|
||||
# PowerShell script to rebuild the Jellyfin solution properly
|
||||
# This script cleans and rebuilds in the correct order to resolve CS0006 metadata errors
|
||||
|
||||
Write-Host "Starting Jellyfin solution rebuild..." -ForegroundColor Cyan
|
||||
|
||||
# Step 1: Clean the solution
|
||||
Write-Host "`n[1/3] Cleaning solution..." -ForegroundColor Yellow
|
||||
dotnet clean Jellyfin.sln --configuration Debug
|
||||
|
||||
# Remove obj and bin directories to ensure clean state
|
||||
Write-Host "`n[2/3] Removing build artifacts..." -ForegroundColor Yellow
|
||||
Get-ChildItem -Path . -Include bin,obj -Recurse -Directory | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||
|
||||
# Step 3: Restore NuGet packages
|
||||
Write-Host "`n[3/3] Restoring NuGet packages..." -ForegroundColor Yellow
|
||||
dotnet restore Jellyfin.sln
|
||||
|
||||
# Step 4: Build the solution
|
||||
Write-Host "`n[4/4] Building solution..." -ForegroundColor Yellow
|
||||
dotnet build Jellyfin.sln --configuration Debug --no-restore
|
||||
|
||||
Write-Host "`nBuild complete!" -ForegroundColor Green
|
||||
Write-Host "If you still see errors, try building specific projects in this order:" -ForegroundColor Cyan
|
||||
Write-Host " 1. Jellyfin.Database.Implementations" -ForegroundColor Gray
|
||||
Write-Host " 2. Jellyfin.Database.Providers.Postgres" -ForegroundColor Gray
|
||||
Write-Host " 3. Jellyfin.Server.Implementations" -ForegroundColor Gray
|
||||
Write-Host " 4. Emby.Server.Implementations" -ForegroundColor Gray
|
||||
Write-Host " 5. Jellyfin.Server" -ForegroundColor Gray
|
||||
@@ -0,0 +1,227 @@
|
||||
# Remove SQLite from Deployment - Quick Implementation
|
||||
# This script removes SQLite dependencies for PostgreSQL-only deployment
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$DryRun,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[switch]$RemoveProject
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$SolutionRoot = "E:\Projects\pgsql-jellyfin"
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "================================================================" -ForegroundColor Cyan
|
||||
Write-Host " Remove SQLite for PostgreSQL-Only Deployment" -ForegroundColor Cyan
|
||||
Write-Host "================================================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
if ($DryRun) {
|
||||
Write-Host "DRY RUN MODE - No changes will be made" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# Step 1: Backup current state
|
||||
Write-Host "Step 1: Creating backup..." -ForegroundColor Cyan
|
||||
if (-not $DryRun) {
|
||||
Push-Location $SolutionRoot
|
||||
git stash push -m "Before SQLite removal"
|
||||
Write-Host " Changes stashed" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " Would stash current changes" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
# Step 2: Find SQLite references
|
||||
Write-Host ""
|
||||
Write-Host "Step 2: Finding SQLite references..." -ForegroundColor Cyan
|
||||
|
||||
$sqliteReferences = @()
|
||||
|
||||
# Check Jellyfin.Server.Implementations
|
||||
$serverImpl = "$SolutionRoot\Jellyfin.Server.Implementations\Jellyfin.Server.Implementations.csproj"
|
||||
if (Test-Path $serverImpl) {
|
||||
$content = Get-Content $serverImpl -Raw
|
||||
if ($content -match 'Jellyfin\.Database\.Providers\.Sqlite') {
|
||||
Write-Host " Found: SQLite reference in Jellyfin.Server.Implementations" -ForegroundColor Yellow
|
||||
$sqliteReferences += @{
|
||||
File = $serverImpl
|
||||
Pattern = '<ProjectReference Include="[^"]*Jellyfin\.Database\.Providers\.Sqlite[^"]*" />'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Check Emby.Server.Implementations
|
||||
$embyImpl = "$SolutionRoot\Emby.Server.Implementations\Emby.Server.Implementations.csproj"
|
||||
if (Test-Path $embyImpl) {
|
||||
$content = Get-Content $embyImpl -Raw
|
||||
if ($content -match 'Microsoft\.Data\.Sqlite') {
|
||||
Write-Host " Found: SQLite package in Emby.Server.Implementations" -ForegroundColor Yellow
|
||||
$sqliteReferences += @{
|
||||
File = $embyImpl
|
||||
Pattern = '<PackageReference Include="Microsoft\.Data\.Sqlite"[^/]*/>'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($sqliteReferences.Count -eq 0) {
|
||||
Write-Host " No SQLite references found" -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Step 3: Remove references
|
||||
Write-Host ""
|
||||
Write-Host "Step 3: Removing SQLite references..." -ForegroundColor Cyan
|
||||
|
||||
foreach ($ref in $sqliteReferences) {
|
||||
$fileName = Split-Path $ref.File -Leaf
|
||||
Write-Host " Processing: $fileName" -ForegroundColor Gray
|
||||
|
||||
if (-not $DryRun) {
|
||||
$content = Get-Content $ref.File -Raw
|
||||
$newContent = $content -replace $ref.Pattern, ''
|
||||
$newContent = $newContent -replace '(\r?\n){3,}', "`r`n`r`n"
|
||||
Set-Content -Path $ref.File -Value $newContent -NoNewline
|
||||
Write-Host " Removed reference" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " Would remove SQLite reference" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
|
||||
# Step 4: Exclude SQLite project from solution (optional)
|
||||
if ($RemoveProject) {
|
||||
Write-Host ""
|
||||
Write-Host "Step 4: Excluding SQLite project from solution..." -ForegroundColor Cyan
|
||||
|
||||
$solutionFile = "$SolutionRoot\Jellyfin.sln"
|
||||
if (Test-Path $solutionFile) {
|
||||
if (-not $DryRun) {
|
||||
$slnContent = Get-Content $solutionFile -Raw
|
||||
$pattern = '(Project\("[^"]*"\) = "Jellyfin\.Database\.Providers\.Sqlite"[^E]*EndProject)'
|
||||
$replacement = "# REMOVED: SQLite Provider`r`n# " + '$1'
|
||||
$newSlnContent = $slnContent -replace $pattern, $replacement
|
||||
Set-Content -Path $solutionFile -Value $newSlnContent -NoNewline
|
||||
Write-Host " SQLite project commented out in solution" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " Would comment out SQLite project" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Step 5: Clean build directories
|
||||
Write-Host ""
|
||||
Write-Host "Step 5: Cleaning build directories..." -ForegroundColor Cyan
|
||||
|
||||
$buildDirs = @(
|
||||
"$SolutionRoot\lib",
|
||||
"$SolutionRoot\Jellyfin.Server.Implementations\bin",
|
||||
"$SolutionRoot\Jellyfin.Server.Implementations\obj",
|
||||
"$SolutionRoot\Emby.Server.Implementations\bin",
|
||||
"$SolutionRoot\Emby.Server.Implementations\obj"
|
||||
)
|
||||
|
||||
foreach ($dir in $buildDirs) {
|
||||
if (Test-Path $dir) {
|
||||
if (-not $DryRun) {
|
||||
Remove-Item $dir -Recurse -Force
|
||||
$dirName = Split-Path $dir -Leaf
|
||||
Write-Host " Cleaned: $dirName" -ForegroundColor Green
|
||||
} else {
|
||||
$dirName = Split-Path $dir -Leaf
|
||||
Write-Host " Would clean: $dirName" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Step 6: Test build
|
||||
Write-Host ""
|
||||
Write-Host "Step 6: Testing build..." -ForegroundColor Cyan
|
||||
|
||||
if (-not $DryRun) {
|
||||
Push-Location $SolutionRoot
|
||||
|
||||
Write-Host " Building solution..." -ForegroundColor Gray
|
||||
$buildOutput = dotnet build --configuration Release 2>&1
|
||||
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Host " Build successful" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " Build failed" -ForegroundColor Red
|
||||
Write-Host $buildOutput
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Rolling back changes..." -ForegroundColor Yellow
|
||||
git stash pop
|
||||
exit 1
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
} else {
|
||||
Write-Host " Would run: dotnet build --configuration Release" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
# Step 7: Verify no SQLite DLLs
|
||||
Write-Host ""
|
||||
Write-Host "Step 7: Verifying no SQLite DLLs..." -ForegroundColor Cyan
|
||||
|
||||
$libFolder = "$SolutionRoot\lib\Release\net11.0"
|
||||
if (Test-Path $libFolder) {
|
||||
$sqliteDlls = Get-ChildItem $libFolder -Filter "*Sqlite*" -Recurse
|
||||
|
||||
if ($sqliteDlls.Count -eq 0) {
|
||||
Write-Host " No SQLite DLLs found in output" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host " Found SQLite DLLs:" -ForegroundColor Yellow
|
||||
$sqliteDlls | ForEach-Object {
|
||||
Write-Host " - $($_.Name)" -ForegroundColor Gray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Step 8: Calculate size reduction
|
||||
Write-Host ""
|
||||
Write-Host "Step 8: Calculating deployment size..." -ForegroundColor Cyan
|
||||
|
||||
if (Test-Path $libFolder) {
|
||||
$totalSize = (Get-ChildItem $libFolder -Recurse -File | Measure-Object -Property Length -Sum).Sum
|
||||
$sizeMB = [math]::Round($totalSize / 1MB, 2)
|
||||
Write-Host " Deployment size: $sizeMB MB" -ForegroundColor White
|
||||
}
|
||||
|
||||
# Summary
|
||||
Write-Host ""
|
||||
Write-Host "================================================================" -ForegroundColor Green
|
||||
Write-Host " SQLite Removal Complete" -ForegroundColor Green
|
||||
Write-Host "================================================================" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
if (-not $DryRun) {
|
||||
Write-Host "Changes made:" -ForegroundColor Cyan
|
||||
Write-Host " - Removed SQLite project references" -ForegroundColor Green
|
||||
Write-Host " - Removed SQLite package references" -ForegroundColor Green
|
||||
if ($RemoveProject) {
|
||||
Write-Host " - Excluded SQLite project from solution" -ForegroundColor Green
|
||||
}
|
||||
Write-Host " - Cleaned build directories" -ForegroundColor Green
|
||||
Write-Host " - Verified build" -ForegroundColor Green
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Next steps:" -ForegroundColor Cyan
|
||||
Write-Host " 1. Review changes: git diff" -ForegroundColor Gray
|
||||
Write-Host " 2. Test application: dotnet run --project Jellyfin.Server" -ForegroundColor Gray
|
||||
Write-Host " 3. Commit changes: git commit -am 'Remove SQLite support'" -ForegroundColor Gray
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Rollback if needed:" -ForegroundColor Yellow
|
||||
Write-Host " git stash pop" -ForegroundColor Gray
|
||||
} else {
|
||||
Write-Host "Dry run complete - no changes made" -ForegroundColor Yellow
|
||||
Write-Host "Run without -DryRun to apply changes" -ForegroundColor Gray
|
||||
}
|
||||
|
||||
if (-not $DryRun) {
|
||||
Pop-Location
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Reference in New Issue
Block a user