Files
KisStock0/backend/migrate_db_v3.py
2026-02-04 00:16:34 +09:00

19 lines
571 B
Python

from sqlalchemy import create_engine, text
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DB_URL = f"sqlite:///{os.path.join(BASE_DIR, 'kis_stock.db')}"
engine = create_engine(DB_URL)
def migrate():
with engine.connect() as conn:
try:
conn.execute(text("ALTER TABLE watchlist ADD COLUMN is_monitoring BOOLEAN DEFAULT 1"))
print("Added is_monitoring column to watchlist")
except Exception as e:
print(f"Column might already exist: {e}")
if __name__ == "__main__":
migrate()