Skip to content

Commit

Permalink
Update Merge Blitz.ps1 so not hardcoded to directory path
Browse files Browse the repository at this point in the history
This change updates the script such that it'll run on other
peoples' machines, even when they don't have a folder path
that is specific to Brent's developer machine.
  • Loading branch information
DanielLoth committed Dec 5, 2024
1 parent fbc68d6 commit 7c09213
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions Documentation/Development/Merge Blitz.ps1
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
#Set your file path
$FilePath = "/Users/brentozar/LocalOnly/Github/SQL-Server-First-Responder-Kit"
$SqlVersionsPath = "$FilePath/SqlServerVersions.sql"
$BlitzFirstPath = "$FilePath/sp_BlitzFirst.sql"
$RepoRootPath = $PSScriptRoot
$RepoRootPath = Join-Path -Path $RepoRootPath -ChildPath ".."
$RepoRootPath = Join-Path -Path $RepoRootPath -ChildPath ".."
$RepoRootPath = Resolve-Path -Path $RepoRootPath

$SqlVersionsPath = "$RepoRootPath/SqlServerVersions.sql"
$BlitzFirstPath = "$RepoRootPath/sp_BlitzFirst.sql"

#Azure - skip sp_Blitz, sp_BlitzBackups, sp_DatabaseRestore, sp_ineachdb
Get-ChildItem -Path "$FilePath" -Filter "sp_Blitz*.sql" |
Get-ChildItem -Path "$RepoRootPath" -Filter "sp_Blitz*.sql" |
Where-Object { $_.FullName -notlike "*sp_Blitz.sql*" -and $_.FullName -notlike "*sp_BlitzBackups*" -and $_.FullName -notlike "*sp_DatabaseRestore*"} |
ForEach-Object { Get-Content $_.FullName } |
Set-Content -Path "$FilePath/Install-Azure.sql" -Force
ForEach-Object { Get-Content $_.FullName } |
Set-Content -Path "$RepoRootPath/Install-Azure.sql" -Force
if ( test-path "$BlitzFirstPath")
{ Add-Content -Path "$FilePath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")}
{ Add-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")}


#All Scripts
Get-ChildItem -Path "$FilePath" -Filter "sp_*.sql" |
Get-ChildItem -Path "$RepoRootPath" -Filter "sp_*.sql" |
Where-Object { $_.FullName -notlike "*sp_BlitzInMemoryOLTP*" -and $_.FullName -notlike "*sp_BlitzFirst*"} |
ForEach-Object { Get-Content $_.FullName } |
Set-Content -Path "$FilePath/Install-All-Scripts.sql" -Force
ForEach-Object { Get-Content $_.FullName } |
Set-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Force
#append script to (re-)create SqlServerVersions Table (https://github.com/BrentOzarULTD/SQL-Server-First-Responder-Kit/issues/2429)
if ( test-path "$SqlVersionsPath")
{ Add-Content -Path "$FilePath/Install-All-Scripts.sql" -Value (Get-Content -Path "$SqlVersionsPath")}
{ Add-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Value (Get-Content -Path "$SqlVersionsPath")}
if ( test-path "$BlitzFirstPath")
{ Add-Content -Path "$FilePath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")}
{ Add-Content -Path "$RepoRootPath/Install-All-Scripts.sql" -Value (Get-Content -Path "$BlitzFirstPath")}

0 comments on commit 7c09213

Please sign in to comment.