refactor: Prevent duplicate table creation messages in trading_plan table

This commit is contained in:
Bobby (aider) 2025-02-12 17:54:46 -08:00
parent f291cd631f
commit 11da135ea2

View File

@ -78,6 +78,18 @@ def create_trading_plan_table():
"""Create the trading plans table if it doesn't exist"""
with create_client() as client:
try:
# First check if table exists
check_query = """
SELECT name
FROM system.tables
WHERE database = currentDatabase()
AND name = 'trading_plans'
"""
result = client.query(check_query)
if result.result_rows:
return # Table already exists, silently return
# Create new table with a structure that supports updates
query = """
CREATE TABLE IF NOT EXISTS trading_plans