headscale-tailscale-replace.../clean-database.py
시골약사 35ecd4748e PharmQ SaaS 구독 서비스 관리 시스템 완전 구현
📋 기획 및 설계:
- PharmQ SaaS 서비스 기획서 작성
- 구독 서비스 라인업 정의 (클라우드PC, AI CCTV, CRM)
- DB 스키마 설계 및 API 아키텍처 설계

🗄️ 데이터베이스 구조:
- service_products: 서비스 상품 마스터 테이블
- pharmacy_subscriptions: 약국별 구독 현황 테이블
- subscription_usage_logs: 서비스 이용 로그 테이블
- billing_history: 결제 이력 테이블
- 샘플 데이터 자동 생성 (21개 구독, 월 118만원 매출)

🔧 백엔드 API 구현:
- 구독 현황 통계 API (/api/subscriptions/stats)
- 약국별 구독 조회 API (/api/pharmacies/subscriptions)
- 구독 상세 정보 API (/api/pharmacy/{id}/subscriptions)
- 구독 생성/해지 API (/api/subscriptions)

🖥️ 프론트엔드 UI 구현:
- 대시보드 구독 현황 카드 (월 매출, 구독 수, 구독률 등)
- 약국 목록에 구독 상태 아이콘 및 월 구독료 표시
- 약국 상세 페이지 구독 서비스 섹션 추가
- 실시간 구독 생성/해지 기능 구현

 주요 특징:
- 서비스별 색상 코딩 및 이모지 아이콘 시스템
- 실시간 업데이트 (구독 생성/해지 즉시 반영)
- 반응형 디자인 (모바일/태블릿 최적화)
- 툴팁 기반 상세 정보 표시

📊 현재 구독 현황:
- 총 월 매출: ₩1,180,000
- 구독 약국: 10/14개 (71.4%)
- AI CCTV: 6개 약국, CRM: 10개 약국, 클라우드PC: 5개 약국

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-11 19:48:12 +09:00

74 lines
2.6 KiB
Python

#!/usr/bin/env python3
"""
데이터베이스 정리 - 문제가 되는 테이블들 제거
"""
import sqlite3
import os
from datetime import datetime
def clean_database():
"""문제가 되는 테이블들 제거"""
db_path = '/srv/headscale-setup/data/db.sqlite'
backup_path = f'/srv/headscale-setup/data/db.sqlite.clean_backup.{datetime.now().strftime("%Y%m%d_%H%M%S")}'
print("🧹 데이터베이스 정리 - 문제 테이블 제거")
print("=" * 50)
# 백업 생성
print(f"📦 백업 생성: {backup_path}")
import shutil
shutil.copy2(db_path, backup_path)
# 데이터베이스 연결
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
try:
# 외래키 제약조건 비활성화
cursor.execute("PRAGMA foreign_keys = OFF")
# 문제가 되는 테이블들 확인
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%pharmacy%'")
problem_tables = cursor.fetchall()
print(f"🎯 제거할 테이블들: {[table[0] for table in problem_tables]}")
# 테이블들 제거
for table in problem_tables:
table_name = table[0]
print(f"🗑️ 테이블 제거: {table_name}")
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
# monitoring_data, machine_specs 등도 제거 (필요시)
additional_tables = ['monitoring_data', 'machine_specs']
for table_name in additional_tables:
cursor.execute(f"SELECT name FROM sqlite_master WHERE type='table' AND name='{table_name}'")
if cursor.fetchone():
print(f"🗑️ 추가 테이블 제거: {table_name}")
cursor.execute(f"DROP TABLE IF EXISTS {table_name}")
# 변경사항 커밋
conn.commit()
# 남은 테이블 확인
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")
remaining_tables = cursor.fetchall()
print(f"✅ 남은 테이블들: {[table[0] for table in remaining_tables]}")
# 무결성 검사
cursor.execute("PRAGMA integrity_check")
integrity = cursor.fetchone()[0]
print(f"🔍 무결성 검사: {integrity}")
print("✅ 데이터베이스 정리 완료!")
print(f"📦 백업 위치: {backup_path}")
except Exception as e:
print(f"❌ 오류: {e}")
conn.rollback()
raise
finally:
conn.close()
if __name__ == '__main__':
clean_database()