Rappi2 uses Alembic to manage the PostgreSQL schema and creates MongoDB indexes automatically on startup viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JorLOrT/rappi2/llms.txt
Use this file to discover all available pages before exploring further.
ensure_all_indexes(). You need to run migrations once after cloning the project, and again whenever a new revision is added.
Running migrations
Apply all pending migrations to bring the schema to the latest revision:api container:
TIMESTAMP WITH TIME ZONE.
Creating a new migration
After modifying SQLAlchemy models, generate a migration automatically:alembic/versions/, then apply it:
MongoDB indexes
MongoDB indexes are created automatically every time the API starts, by callingensure_all_indexes() during the application lifespan. You do not need to run any command manually.
The following indexes are created across the configured MONGO_DB database:
| Collection | Index | Type |
|---|---|---|
gps_tracking | location | 2dsphere (geospatial) |
gps_tracking | asignacion_id + timestamp | Compound |
geocercas | geometry | 2dsphere (geospatial) |
geocercas | ruta_id + activa | Compound |
auditoria | usuario_id + timestamp | Compound |
auditoria | timestamp | TTL — records expire after 90 days |
notificaciones | destinatario_tipo + destinatario_id + fecha | Compound |
notificaciones | leida | Single field |
evidencias | incidencia_id | Single field |
evidencias | archivos.file_id | Single field |
Seeding initial data
Run the seed script to create the default roles and admin user:- Roles:
Admin,Despachador,Conductor,Cliente - Permissions: a wildcard
*:*permission assigned to theAdminrole - Admin user: username
admin, passwordadmin123, emailadmin@rappi2.com
Checking database health
Verify that PostgreSQL is reachable and the schema is applied:Alembic migrations are idempotent — running
alembic upgrade head when the schema is already up to date completes without making any changes.