From ae1782a6de3d12d2c2564887cc3e94b1df21ecf2 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 14 Nov 2025 10:53:59 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20P001,=20P002=20=EC=95=BD=EA=B5=AD=20?= =?UTF-8?q?=EB=B3=B4=ED=98=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 문제: - cleanup 스크립트가 P0003 이후 삭제 시 P001, P002도 함께 삭제됨 - 문자열 비교 'P001' >= 'P0003'이 true로 평가됨 원인: - SQLite 문자열 비교에서 'P001' < 'P0003'이지만 - 'P002' >= 'P0003'은 false인데, 기존 조건이 잘못됨 해결: - LENGTH(pharmacy_code) = 5 조건 추가 - P0003 <= pharmacy_code <= P9999 범위 명시 - P001, P002 (4자), P0001, P0002 (5자) 모두 보호 변경 파일: - cleanup-test-data.sh: 삭제 쿼리 수정 - CLEANUP_TEST_DATA.md: 문서 업데이트 보호되는 약국: - P001: default 약국 (4자) - P002: 새서울약국 (4자) - P0002: 청춘약국 (5자, 범위 밖) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CLEANUP_TEST_DATA.md | 8 ++++---- cleanup-test-data.sh | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CLEANUP_TEST_DATA.md b/CLEANUP_TEST_DATA.md index 8246a9b..863c8a0 100644 --- a/CLEANUP_TEST_DATA.md +++ b/CLEANUP_TEST_DATA.md @@ -30,9 +30,9 @@ cursor.execute('SELECT pharmacy_code, pharmacy_name, tailscale_ip FROM pharmacie for row in cursor.fetchall(): print(f' {row[0]}: {row[1]} - {row[2]}') -# P0003 이후 약국 삭제 (테스트 데이터) +# P0003~P9999 약국 삭제 (P001, P002, P0001, P0002는 보호) print('\nP0003 이후 약국 삭제 중...') -cursor.execute("DELETE FROM pharmacies WHERE pharmacy_code >= 'P0003' AND pharmacy_code < 'P1000'") +cursor.execute("DELETE FROM pharmacies WHERE pharmacy_code >= 'P0003' AND pharmacy_code <= 'P9999' AND LENGTH(pharmacy_code) = 5") deleted_count = cursor.rowcount conn.commit() @@ -199,9 +199,9 @@ curl -fsSL https://raw.githubusercontent.com/thug0bin/pve9-repo-fix/main/cleanup ### 시나리오 1: 전체 테스트 데이터 정리 ```bash -# 1. farmq.db 정리 (P0003 이후) +# 1. farmq.db 정리 (P0003~P9999, P001/P002 보호) cd /srv/headscale-tailscale-replacement/farmq-admin -python3 -c "import sqlite3; conn = sqlite3.connect('farmq.db'); cursor = conn.cursor(); cursor.execute(\"DELETE FROM pharmacies WHERE pharmacy_code >= 'P0003' AND pharmacy_code < 'P1000'\"); conn.commit(); print(f'✓ {cursor.rowcount}개 약국 삭제'); conn.close()" +python3 -c "import sqlite3; conn = sqlite3.connect('farmq.db'); cursor = conn.cursor(); cursor.execute(\"DELETE FROM pharmacies WHERE pharmacy_code >= 'P0003' AND pharmacy_code <= 'P9999' AND LENGTH(pharmacy_code) = 5\"); conn.commit(); print(f'✓ {cursor.rowcount}개 약국 삭제'); conn.close()" # 2. gateway.db 정리 (ID 5 이후) cd /srv/pharmq-gateway diff --git a/cleanup-test-data.sh b/cleanup-test-data.sh index fefcdd8..1239097 100755 --- a/cleanup-test-data.sh +++ b/cleanup-test-data.sh @@ -64,7 +64,8 @@ EOF import sqlite3 conn = sqlite3.connect('$FARMQ_DB') cursor = conn.cursor() -cursor.execute("DELETE FROM pharmacies WHERE pharmacy_code >= 'P0003' AND pharmacy_code < 'P1000'") +# P0003~P9999만 삭제 (P001, P002, P0001, P0002는 보호) +cursor.execute("DELETE FROM pharmacies WHERE pharmacy_code >= 'P0003' AND pharmacy_code <= 'P9999' AND LENGTH(pharmacy_code) = 5") deleted_count = cursor.rowcount conn.commit() conn.close()