[add]: ref_id and ref_model for transactions. And db session and rollback for transactions

This commit is contained in:
VivianDee
2025-04-10 23:06:51 +01:00
parent e5320c075e
commit a196d4d3c4
14 changed files with 123 additions and 88 deletions
+1 -4
View File
@@ -47,9 +47,7 @@ class Loan(db.Model):
try:
db.session.add(loan)
db.session.commit()
except IntegrityError as err:
db.session.rollback()
raise ValueError(f"Database integrity error: {err}")
return loan
@@ -92,8 +90,7 @@ class Loan(db.Model):
# Update loan status and the updated_at timestamp
loan.status = status
db.session.commit()
def __repr__(self):
return f'<Loan {self.id}>'