fix(database): generate unique phone numbers in seed data
name: Bug Report
about: Report a bug in the Corpus Collector Backend.
title: "[Bug]: "
labels: "bug"
assignees: ''
title: "fix(database): generate unique phone numbers in seed data"
🐛 Bug Report
Describe the bug
The database seeding script assigns the same hardcoded phone number 9876543210 to all users (admins, doctors, volunteers, coordinators, and patients), preventing proper testing of phone-based authentication and violating data uniqueness expectations.
To Reproduce
Steps to reproduce the behavior:
- Run database seeding:
sudo docker compose exec api python -m scripts.seed_database --clear - Check the output sample login credentials
- Observe that all users have the same phone number:
9876543210 - Query the database to verify all users share the same phone number
Expected behavior
Each user should have a unique 10-digit Indian mobile phone number starting with 6, 7, 8, or 9 to enable:
- Proper phone-based authentication testing
- Realistic user data simulation
- Unique user identification by phone number
Screenshots
N/A - Terminal output shows duplicate phone numbers in seed data output.
Environment
- OS: Linux (Docker container)
- Database: PostgreSQL 16
- Python: 3.10
- Framework: FastAPI
Additional context
Root Cause: The _generate_indian_phone() method in scripts/factories/user_factory.py returns a hardcoded value instead of generating unique numbers.
Solution: Updated the method to generate random 10-digit Indian mobile numbers:
def _generate_indian_phone(self) -> str:
first_digit = random.choice(['6', '7', '8', '9'])
remaining_digits = ''.join([str(random.randint(0, 9)) for _ in range(9)])
return first_digit + remaining_digits
Fixed in: Branch dummy-db-dev, Commit 36df750
📌 Follow semantic issue titling convention:<type>(<scope>): <description>(e.g.,fix(auth): resolve jwt token expirationorchore(deps): update dependencies).