$migrationDir = 'c:\VietProDev\sso\sso-vietprodev-backend\sql\migrations'
$seedDir = 'c:\VietProDev\sso\sso-vietprodev-backend\sql\seeds'

# Replacement map
$replacements = @{
    'BeKind Backend'               = 'SSO VietProDev Backend'
    'BeKind Property'              = 'SSO VietProDev'
    'bekind-dev.meucorp.com'       = 'sso-dev.vietprodev.com'
    'bekind_backend'               = 'sso_vietprodev'
    'bekind-backend'               = 'sso-vietprodev'
    'admin@bekind.com'             = 'admin@sso.vietprodev.com'
    'user@bekind.com'              = 'user@sso.vietprodev.com'
    'BeKind'                       = 'SSO VietProDev'
}

# Process all .sql files in migrations/ and seeds/
$dirs = @($migrationDir, $seedDir)
foreach ($dir in $dirs) {
    Get-ChildItem -Path $dir -Filter '*.sql' -Recurse | ForEach-Object {
        $file = $_.FullName
        $content = Get-Content -Path $file -Raw
        $original = $content
        foreach ($key in $replacements.Keys) {
            $content = $content -replace [regex]::Escape($key), $replacements[$key]
        }
        if ($content -ne $original) {
            Set-Content -Path $file -Value $content -NoNewline
            Write-Host "Updated: $file"
        }
    }
}