Added source column

This commit is contained in:
bolade
2025-10-23 23:11:13 +01:00
parent 7296d09319
commit 2f917ec085
3 changed files with 37 additions and 14 deletions
+7 -4
View File
@@ -29,23 +29,25 @@ Base = declarative_base()
def create_db_tables():
"""Create database tables safely with error handling"""
import logging
logger = logging.getLogger(__name__)
try:
# Check if tables already exist to avoid unnecessary DDL operations
from sqlalchemy import inspect
inspector = inspect(engine)
existing_tables = inspector.get_table_names()
if existing_tables:
logger.info(f"Database tables already exist: {existing_tables}")
return
# Create tables with timeout protection
logger.info("Creating database tables...")
Base.metadata.create_all(bind=engine, checkfirst=True)
logger.info("Database tables created successfully")
except KeyboardInterrupt:
logger.warning("Database creation interrupted by user")
raise
@@ -81,6 +83,7 @@ class DBTransaction(Base):
tax_amount = Column(Float, nullable=True)
categorisation_id = Column(String, nullable=True)
user_id = Column(String, nullable=True)
source = Column(String, nullable=True) # e.g., "csv", "image", "manual", "api"
# Additional QuickBooks CSV columns
TxnId = Column(String, nullable=True)