flnxi-Wu/scripts/tools/clear-users-table.ps1
WuYongJie d1c6efc79d
Some checks failed
CI Check / check (push) Has been cancelled
feat: NAS 部署与 Harbor 推送流程
2025-12-03 14:39:06 +08:00

26 lines
1.2 KiB
PowerShell

# 清空用户表脚本
param(
[string]$Server = "45.249.208.118",
[string]$Username = "root",
[string]$Password = "lxvhNYFZ4160",
[string]$Database = "flnxi"
)
$plinkPath = "C:\Program Files\PuTTY\plink.exe"
$hostKey = "SHA256:WZOtvC/+IWw29P8vyovSabmIRFkQ/Bnmhj+qhTshA4Q"
Write-Host "检查当前用户数量..." -ForegroundColor Cyan
$checkCmd = "cd /root/deploy && docker compose exec -T postgres psql -U postgres -d $Database -c 'SELECT COUNT(*) as user_count FROM users;'"
& $plinkPath -batch -ssh -hostkey $hostKey -pw $Password "${Username}@${Server}" $checkCmd
Write-Host "`n清空用户表..." -ForegroundColor Yellow
$truncateCmd = "cd /root/deploy && docker compose exec -T postgres psql -U postgres -d $Database -c 'TRUNCATE TABLE users CASCADE;'"
& $plinkPath -batch -ssh -hostkey $hostKey -pw $Password "${Username}@${Server}" $truncateCmd
Write-Host "`n验证用户表已清空..." -ForegroundColor Cyan
$verifyCmd = "cd /root/deploy && docker compose exec -T postgres psql -U postgres -d $Database -c 'SELECT COUNT(*) as user_count FROM users;'"
& $plinkPath -batch -ssh -hostkey $hostKey -pw $Password "${Username}@${Server}" $verifyCmd
Write-Host "`n✓ 用户表已清空,可以测试首位注册用户功能" -ForegroundColor Green