fix_tenant_id_column_name.ps1 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. # 统一 Entity 中的 tenant_id 字段名脚本
  2. $entityFolders = @(
  3. "d:\DEMONET\server\Plugins\Admin.NET.Plugin.AiDOP\Order\Entity",
  4. "d:\DEMONET\server\Plugins\Admin.NET.Plugin.AiDOP\Production\Entity"
  5. )
  6. $corrected = @()
  7. foreach ($folder in $entityFolders) {
  8. if (!(Test-Path $folder)) { continue }
  9. $files = Get-ChildItem -Path $folder -Filter "*.cs"
  10. foreach ($file in $files) {
  11. $content = Get-Content $file.FullName -Raw
  12. # 检查是否有 TenantId(Pascal命名)的 ColumnName
  13. if ($content -match 'ColumnName = "TenantId"') {
  14. # 将 ColumnName = "TenantId" 改为 ColumnName = "tenant_id"
  15. $content = $content -replace 'ColumnName = "TenantId"', 'ColumnName = "tenant_id"'
  16. [System.IO.File]::WriteAllText($file.FullName, $content, [System.Text.Encoding]::UTF8)
  17. Write-Host "Corrected: $($file.Name)" -ForegroundColor Green
  18. $corrected += $file.Name
  19. }
  20. }
  21. }
  22. Write-Host "`nCorrected $($corrected.Count) files to use 'tenant_id'" -ForegroundColor Cyan
  23. $corrected | ForEach-Object { Write-Host " - $_" -ForegroundColor Green }