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:
@@ -68,6 +68,7 @@ def add_vendor_domain(
|
||||
domain = vendor_domain_service.add_domain(
|
||||
db=db, vendor_id=vendor_id, domain_data=domain_data
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return VendorDomainResponse(
|
||||
id=domain.id,
|
||||
@@ -186,6 +187,7 @@ def update_vendor_domain(
|
||||
domain = vendor_domain_service.update_domain(
|
||||
db=db, domain_id=domain_id, domain_update=domain_update
|
||||
)
|
||||
db.commit()
|
||||
|
||||
return VendorDomainResponse(
|
||||
id=domain.id,
|
||||
@@ -224,6 +226,7 @@ def delete_vendor_domain(
|
||||
|
||||
# Delete domain
|
||||
message = vendor_domain_service.delete_domain(db, domain_id)
|
||||
db.commit()
|
||||
|
||||
return DomainDeletionResponse(
|
||||
message=message, domain=domain_name, vendor_id=vendor_id
|
||||
@@ -259,6 +262,7 @@ def verify_domain_ownership(
|
||||
- 502: DNS query failed
|
||||
"""
|
||||
domain, message = vendor_domain_service.verify_domain(db, domain_id)
|
||||
db.commit()
|
||||
|
||||
return DomainVerificationResponse(
|
||||
message=message,
|
||||
|
||||
Reference in New Issue
Block a user