Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $config = Get-Content -Raw deploy.json | ConvertFrom-Json
- $output = $config.build.output_file
- Write-Host "Building merged deploy script for database" $config.database.name.ToUpper()
- Write-Host "Output file:" $output
- foreach ($schema in $config.database.schemas)
- {
- Write-Host "Building objects for schema" $schema.ToUpper()
- $files = Get-ChildItem -Path .\schemas\$schema\tables -Filter "*.sql"
- foreach ($file in $files) {
- Write-host $file.name
- $text = Get-Content -Raw $file.FullName
- $text=$text -replace("(?m)--.*?\r?\n?","")
- $text=$text -replace("\/\*.*?\*\/\r?\n?","")
- $mergedSQL += "-- From file: $($file.name)`n"
- $mergedSQL += $text
- $mergedSQL += "`n"
- Set-Content $output -Value $mergedSQL
- }
- }
Add Comment
Please, Sign In to add comment