# ============================================================================ # Script: 06_update_docs.ps1 # Purpose: Update documentation files to reference new table names # Target: ShopDB markdown files on Windows # # USAGE: # cd C:\path\to\shopdb # .\sql\naming_convention_fix\06_update_docs.ps1 # .\sql\naming_convention_fix\06_update_docs.ps1 -Execute # # This is lower priority - docs can be updated anytime after migration # ============================================================================ param( [switch]$Execute ) Write-Host "============================================" -ForegroundColor Cyan Write-Host "Documentation Table Name Updates" -ForegroundColor Cyan Write-Host "============================================" -ForegroundColor Cyan Write-Host "" # Define replacements $replacements = @{ "machine_overrides" = "machineoverrides" "pc_comm_config" = "commconfig" "pc_dnc_config" = "dncconfig" "pc_dualpath_assignments" = "dualpathassignments" "pc_network_interfaces" = "networkinterfaces" "usb_checkouts" = "usbcheckouts" } # Get the shopdb root directory (two levels up from script location) $shopdbRoot = Join-Path $PSScriptRoot "..\..\" Write-Host "Searching for documentation files with old table names..." -ForegroundColor Yellow Write-Host "Directory: $shopdbRoot" -ForegroundColor Gray Write-Host "" # Find all markdown files $mdFiles = Get-ChildItem -Path $shopdbRoot -Filter "*.md" -Recurse -ErrorAction SilentlyContinue $filesToUpdate = @{} foreach ($oldName in $replacements.Keys) { $newName = $replacements[$oldName] Write-Host "--- $oldName -> $newName ---" -ForegroundColor Green $matchingFiles = @() foreach ($file in $mdFiles) { $content = Get-Content $file.FullName -Raw -ErrorAction SilentlyContinue if ($content -match [regex]::Escape($oldName)) { $count = ([regex]::Matches($content, [regex]::Escape($oldName))).Count $relativePath = $file.FullName.Replace((Resolve-Path $shopdbRoot).Path, "") Write-Host " $relativePath ($count occurrences)" -ForegroundColor White if (-not $filesToUpdate.ContainsKey($file.FullName)) { $filesToUpdate[$file.FullName] = @() } $filesToUpdate[$file.FullName] += $oldName } } if ($matchingFiles.Count -eq 0) { # Already printed matches above } Write-Host "" } Write-Host "Total files to update: $($filesToUpdate.Count)" -ForegroundColor Yellow Write-Host "" if ($Execute) { Write-Host "============================================" -ForegroundColor Cyan Write-Host "EXECUTING CHANGES..." -ForegroundColor Cyan Write-Host "============================================" -ForegroundColor Cyan Write-Host "" foreach ($filePath in $filesToUpdate.Keys) { $content = Get-Content $filePath -Raw foreach ($oldName in $replacements.Keys) { $newName = $replacements[$oldName] if ($content -match [regex]::Escape($oldName)) { $content = $content -replace [regex]::Escape($oldName), $newName } } Set-Content -Path $filePath -Value $content -NoNewline $relativePath = $filePath.Replace((Resolve-Path $shopdbRoot).Path, "") Write-Host "Updated: $relativePath" -ForegroundColor Green } Write-Host "" Write-Host "Documentation updated successfully!" -ForegroundColor Green } else { Write-Host "============================================" -ForegroundColor Yellow Write-Host "DRY RUN COMPLETE" -ForegroundColor Yellow Write-Host "============================================" -ForegroundColor Yellow Write-Host "To apply changes, run:" -ForegroundColor White Write-Host " .\sql\naming_convention_fix\06_update_docs.ps1 -Execute" -ForegroundColor Cyan Write-Host "" Write-Host "NOTE: Documentation updates are low priority." -ForegroundColor Gray Write-Host " Focus on database and ASP changes first." -ForegroundColor Gray }