refactor: move transaction management from services to API endpoints
- Services now use db.flush() instead of db.commit() for database operations - API endpoints handle transaction commit after service calls - Remove db.rollback() from services (let exception handlers manage this) - Ensures consistent transaction boundaries at API layer This pattern gives API endpoints full control over when to commit, allowing for better error handling and potential multi-operation transactions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -211,7 +211,7 @@ class ContentPageService:
|
||||
)
|
||||
|
||||
db.add(page)
|
||||
db.commit()
|
||||
db.flush()
|
||||
db.refresh(page)
|
||||
|
||||
logger.info(
|
||||
@@ -288,7 +288,7 @@ class ContentPageService:
|
||||
if updated_by is not None:
|
||||
page.updated_by = updated_by
|
||||
|
||||
db.commit()
|
||||
db.flush()
|
||||
db.refresh(page)
|
||||
|
||||
logger.info(f"Updated content page: id={page_id}, slug={page.slug}")
|
||||
@@ -313,7 +313,6 @@ class ContentPageService:
|
||||
return False
|
||||
|
||||
db.delete(page)
|
||||
db.commit()
|
||||
|
||||
logger.info(f"Deleted content page: id={page_id}, slug={page.slug}")
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user