Added source column
This commit is contained in:
+7
-4
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user