SOY NV AI
Fix: Change POST endpoint from /parent-chunk to /process/parent-chunk and improve error handling
9c8de54
| """ | |
| ๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ง์ด๊ทธ๋ ์ด์ ์คํฌ๋ฆฝํธ | |
| uploaded_file ํ ์ด๋ธ์ is_public ์ปฌ๋ผ์ ์ถ๊ฐํฉ๋๋ค. | |
| """ | |
| import sqlite3 | |
| import os | |
| from pathlib import Path | |
| # ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ฒฝ๋ก | |
| db_path = Path(__file__).parent / 'instance' / 'finance_analysis.db' | |
| def migrate_database(): | |
| """๋ฐ์ดํฐ๋ฒ ์ด์ค์ is_public ์ปฌ๋ผ ์ถ๊ฐ""" | |
| if not db_path.exists(): | |
| print(f"๋ฐ์ดํฐ๋ฒ ์ด์ค ํ์ผ์ด ์์ต๋๋ค: {db_path}") | |
| print("์ฑ์ ์คํํ๋ฉด ์๋์ผ๋ก ์์ฑ๋ฉ๋๋ค.") | |
| return | |
| try: | |
| conn = sqlite3.connect(str(db_path)) | |
| cursor = conn.cursor() | |
| # uploaded_file ํ ์ด๋ธ์ is_public ์ปฌ๋ผ์ด ์๋์ง ํ์ธ | |
| cursor.execute("PRAGMA table_info(uploaded_file)") | |
| columns = [column[1] for column in cursor.fetchall()] | |
| if 'is_public' in columns: | |
| print("is_public ์ปฌ๋ผ์ด ์ด๋ฏธ ์กด์ฌํฉ๋๋ค.") | |
| conn.close() | |
| return | |
| # is_public ์ปฌ๋ผ ์ถ๊ฐ (๊ธฐ๋ณธ๊ฐ: 0 = False) | |
| print("is_public ์ปฌ๋ผ์ ์ถ๊ฐํ๋ ์ค...") | |
| cursor.execute("ALTER TABLE uploaded_file ADD COLUMN is_public BOOLEAN DEFAULT 0") | |
| conn.commit() | |
| print("is_public ์ปฌ๋ผ์ด ์ฑ๊ณต์ ์ผ๋ก ์ถ๊ฐ๋์์ต๋๋ค.") | |
| # ๊ธฐ์กด ๋ฐ์ดํฐ์ is_public ๊ฐ์ 0(False)์ผ๋ก ์ค์ | |
| cursor.execute("UPDATE uploaded_file SET is_public = 0 WHERE is_public IS NULL") | |
| conn.commit() | |
| print("๊ธฐ์กด ๋ฐ์ดํฐ์ is_public ๊ฐ์ 0(False)์ผ๋ก ์ค์ ํ์ต๋๋ค.") | |
| conn.close() | |
| print("๋ง์ด๊ทธ๋ ์ด์ ์ด ์๋ฃ๋์์ต๋๋ค.") | |
| except sqlite3.OperationalError as e: | |
| print(f"์ค๋ฅ ๋ฐ์: {e}") | |
| if "duplicate column name" in str(e).lower() or "already exists" in str(e).lower(): | |
| print("is_public ์ปฌ๋ผ์ด ์ด๋ฏธ ์กด์ฌํฉ๋๋ค.") | |
| else: | |
| raise | |
| except Exception as e: | |
| print(f"์์์น ๋ชปํ ์ค๋ฅ: {e}") | |
| raise | |
| if __name__ == '__main__': | |
| print("=" * 60) | |
| print("๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ง์ด๊ทธ๋ ์ด์ : is_public ์ปฌ๋ผ ์ถ๊ฐ") | |
| print("=" * 60) | |
| migrate_database() | |