Skip to content

Added Numbers to dummy database

Praneeth Ashish requested to merge database-update-num into develop

closes #27 (closed)

Issue: Database Seeding Contains No Phone Numbers

Date: 2026-02-10
Status: Open
Component: Database Seeding Scripts

Problem Description

The database seeding script does not properly populate phone numbers for users, preventing phone-based authentication from working correctly.

Current Behavior

When running the database seed script:

sudo docker compose exec {container-id} python -m scripts.seed_database --clear

The seeded users appear to have missing or improperly formatted phone numbers in the user_phone_no field.

Expected Behavior

All seeded users (admins, doctors, volunteers, coordinators, and patients) should have valid phone numbers in the format that matches the authentication system's requirements.

Impact

  • Phone-based login fails: Users cannot authenticate using phone numbers
  • Testing blocked: Cannot test phone authentication features with seeded data
  • Development workflow disrupted: Developers need valid phone numbers for local testing

Investigation Notes

The UserFactory._generate_indian_phone() method (lines 75-83 in user_factory.py) generates phone numbers in the format:

+91 XXXXX XXXXX

However, the authentication system may expect a different format (e.g., without spaces or country code).

Potential Root Causes

  1. Format mismatch: Generated phone numbers may not match the format expected by the authentication service
  2. Database constraint: Phone numbers might be getting rejected during insertion
  3. Null values: Phone numbers might not be getting saved to the database at all

Reproduction Steps

  1. Clear and seed the database:

    sudo docker compose exec {container-name} python -m scripts.seed_database --clear
  2. Check the database for user phone numbers:

    SELECT user_name, user_phone_no FROM users LIMIT 10;
  3. Attempt to login using a phone number from the seeded data

Suggested Investigation

  1. Verify the actual phone number values in the database after seeding
  2. Check if there are database constraints on the user_phone_no field
  3. Compare the phone number format generated by the factory with what the auth service expects
  4. Review the User model schema for phone number validation rules

Next Steps

  • Verify actual phone number values in database after seeding
  • Identify the expected phone number format for authentication
  • Update _generate_indian_phone() to match required format
  • Add validation to ensure phone numbers are properly saved
  • Update seed script output to display phone numbers for testing
  • Add tests to verify phone number generation and storage
Edited by Praneeth Ashish

Merge request reports

Loading