20 lines
767 B
PowerShell
20 lines
767 B
PowerShell
# 修复 eldercare_mock_data_insert.sql 中的重复键冲突问题
|
|
|
|
$filePath = "h:\blews\akmon\doc_eldercare\eldercare_mock_data_insert.sql"
|
|
$content = Get-Content $filePath -Raw -Encoding UTF8
|
|
|
|
# 查找并替换所有 ak_users INSERT 语句,添加冲突处理
|
|
$pattern = "(INSERT INTO public\.ak_users.*?)\);"
|
|
$replacement = '$1)' + "`nON CONFLICT (id) DO NOTHING;"
|
|
|
|
$updatedContent = $content -replace $pattern, $replacement
|
|
|
|
# 保存更新的文件
|
|
Set-Content $filePath -Value $updatedContent -Encoding UTF8
|
|
|
|
Write-Host "已修复所有 ak_users INSERT 语句的冲突处理"
|
|
|
|
# 验证修复结果
|
|
$conflictCount = ([regex]::Matches($updatedContent, "ON CONFLICT \(id\) DO NOTHING")).Count
|
|
Write-Host "文件中现在有 $conflictCount 个冲突处理语句"
|