fix: delete all duplicate portfolios in seed_data to ensure idempotency
All checks were successful
Deploy to Production / deploy (push) Successful in 2m2s

This commit is contained in:
머니페니 2026-05-13 22:48:01 +09:00
parent fc0a24888d
commit c97f73ab0c

View File

@ -121,15 +121,16 @@ def seed(db: Session):
print("ERROR: No user found in database. Create a user first.")
return
# Delete existing portfolio if present (cascade deletes related records)
existing = db.query(Portfolio).filter(
# Delete all existing portfolios with this name (cascade deletes related records)
existing_list = db.query(Portfolio).filter(
Portfolio.user_id == user.id,
Portfolio.name == "연금 포트폴리오",
).first()
if existing:
).all()
for existing in existing_list:
db.delete(existing)
db.flush()
print(f"Deleted existing portfolio (id={existing.id})")
if existing_list:
db.flush()
# Create portfolio
portfolio = Portfolio(