ms-alumnos ships with a dedicated seed module that gives developers an instant, repeatable starting point. Sending a single NATS message truncates theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Distribuidos-Org/ms-alumnos/llms.txt
Use this file to discover all available pages before exploring further.
alumnos table and inserts 100 realistic student records so you can explore API behaviour, run manual tests, or hand-off a demo environment without crafting fixtures by hand.
How it works
The seed feature is composed of three layers that work together:SeedController — registered as a NestJS microservice controller, it listens for the { cmd: 'seed_alumnos' } message pattern and delegates immediately to SeedService:
SeedService — contains the actual database logic. It first issues a raw TRUNCATE query to wipe existing rows and reset the sequence, then uses the TypeORM repository to bulk-create and save all 100 records from the static data array:
seedAlumnosData (src/seed/data/sees.data.ts) — a static array of 100 objects that conform to the SeedAlumno interface. Each object carries every field required by the Alumno entity so that TypeORM can persist them without additional transformation.
Running the seed
Trigger the seed by publishing a NATS request to theseed_alumnos subject. Any NATS client works; the example below uses the official nats npm package:
{ message: 'Seed ejecutado correctamente', count: 100 }. The count field always reflects the number of rows actually saved, which makes it easy to assert correctness in automated scripts.
Sample data overview
The 100 seed records are spread across four Peruvian universities and a variety of faculties and degree levels, giving a representative cross-section of student data:| Field | Range / Values |
|---|---|
dni | 10000001 – 10000100 (sequential) |
edad | 24 – 35 |
universidad | UNMSM, UNI, PUCP, USMP |
grado | Bachiller, Licenciado, Magíster, Doctor |
egresadoLocal | true or false |
- UNMSM — largest group, primarily from FISI (Ing. Sistemas, Ing. Software) and faculties of Medicina, Psicología, Ciencias, and Letras.
- UNI — engineering-focused: Ing. Civil, Mecánica, Electrónica, Mecatrónica, Ambiental, Química, Eléctrica, and Industrial.
- PUCP — diverse: Derecho, Economía, Psicología, Ciencias Sociales, Arquitectura, Arte, and Ciencias.
- USMP — Medicina, Derecho, Contabilidad, Administración, Comunicación, and Psicología.
@example.com email addresses and the placeholder password contrasena. Do not use these records in a production environment.
Reset behavior
The seed service executes the following SQL before inserting new rows:RESTART IDENTITY resets the PostgreSQL auto-increment sequence back to 1, so the primary keys assigned to the new seed records always start from a predictable value. CASCADE ensures that any foreign-key relationships that reference the alumnos table are also cleaned up automatically.