fix: food migration error and allowed access to volunteer
Overview
This MR fixes two backend issues related to the Food Queue module:
- Alembic migration compatibility failure during
db-init - Volunteer access restriction for Food Queue APIs
What does this MR do and why?
Issues Identified
closes #116 (closed)
-
db-initcontainer failed because Alembic migration attempted to drop indexes/tables that did not exist in some database states. - Volunteers were denied access to Food Queue APIs because certain endpoints were restricted to admin-only roles.
Solution
-
Updated migration scripts to safely handle missing indexes/tables using:
DROP INDEX IF EXISTSDROP TABLE IF EXISTS
-
Updated backend role access configuration to allow volunteers/coordinators to access required Food Queue endpoints.
Changes Made
Migration Fix
- Updated Food Queue Alembic migration for compatibility across different DB states.
- Added safe conditional cleanup for indexes and tables.
Access Control Fix
-
Allowed:
- volunteer
- coordinator
- admin
to access required Food Queue APIs.
Technical Details
Root Cause
Migration Failure
Migration assumed Food Queue indexes/tables always existed, causing failures in partially migrated/local databases.
Access Restriction
RBAC configuration allowed only admin role for endpoints required by volunteers.
Type of Change
-
🐛 Bug fix -
🔧 Backend change -
🚨 Authorization fix
Validation
Migration Validation
Verified Alembic migration generates safe SQL using:
DROP INDEX IF EXISTS
DROP TABLE IF EXISTS
Test Validation
uv run pytest tests/test_api/test_stations_routes.py tests/test_api/test_patient_routes.py -q
Result:
53 passed
Expected Result
-
db-initcontainer starts successfully without migration failure. - Volunteers can access Food Queue APIs without authorization errors.
Edited by Rajuldev Vandana