Fix DB issues

This commit is contained in:
Urtzi Alfaro
2025-09-30 13:32:51 +02:00
parent ec6bcb4c7d
commit 147893015e
51 changed files with 341 additions and 1032 deletions

View File

@@ -110,7 +110,7 @@ async def test_procurement_scheduler():
else:
return {"error": "Scheduler service not available"}
except Exception as e:
logger.error("Error testing procurement scheduler", error=str(e))
service.logger.error("Error testing procurement scheduler", error=str(e))
return {"error": f"Failed to trigger scheduler test: {str(e)}"}
@@ -118,17 +118,17 @@ async def test_procurement_scheduler():
async def logging_middleware(request: Request, call_next):
"""Add request logging middleware"""
import time
start_time = time.time()
response = await call_next(request)
process_time = time.time() - start_time
logger.info("HTTP request processed",
service.logger.info("HTTP request processed",
method=request.method,
url=str(request.url),
status_code=response.status_code,
process_time=round(process_time, 4))
return response

View File

@@ -0,0 +1,21 @@
"""
Orders Service Models Package
Import all models to ensure they are registered with SQLAlchemy Base.
"""
# Import all models to register them with the Base metadata
from .customer import Customer, CustomerContact
from .order import CustomerOrder, OrderItem, OrderStatusHistory
from .procurement import ProcurementPlan, ProcurementRequirement
# List all models for easier access
__all__ = [
"Customer",
"CustomerContact",
"CustomerOrder",
"OrderItem",
"OrderStatusHistory",
"ProcurementPlan",
"ProcurementRequirement"
]