Skip to content

resuelto ejercicio Base de Datos db-AVC#4

Open
valeriianaa wants to merge 2 commits intoLIDR-academy:mainfrom
valeriianaa:db-AVC
Open

resuelto ejercicio Base de Datos db-AVC#4
valeriianaa wants to merge 2 commits intoLIDR-academy:mainfrom
valeriianaa:db-AVC

Conversation

@valeriianaa
Copy link

@valeriianaa valeriianaa commented Nov 15, 2025

Resuelto el ejercicio de Bases de Datos con Visual Studio Code y GitHub Copilot.

En la ultima parte del ejercio tuve un problema al correr la nueva migración pero fue resuelto. El ultimo prompt que escribí se trata de ese error.

Prompt 4 (troubleshooting)
I got this error when running: npx prisma migrate reset:

✔ Are you sure you want to reset your database? All data will be lost. … yes
Applying migration 20251115173741_db_avc Error: P3018

A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve

Migration name: 20251115173741_db_avc

Database error code: 42P01

Database error: ERROR: relation "Education" does not exist

DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42P01), message: "relation "Education" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("namespace.c"), line: Some(636), routine: Some("RangeVarGetRelidExtended") }

Summary by CodeRabbit

  • New Features
    • Full HR/recruitment functionality: company & employee management, job postings, candidate profiles with education/work history and resume uploads, application tracking with statuses, and interview scheduling with configurable steps, types, and results.
  • Documentation
    • Added a comprehensive guide with ER diagrams and prompts describing the recruitment data model and migration troubleshooting steps.

@coderabbitai
Copy link

coderabbitai bot commented Nov 15, 2025

Walkthrough

Adds a full PostgreSQL schema and matching Prisma models for a recruitment/HR domain: 16 new tables/models (Company, EmployeeRole, Employee, Location, EmploymentType, Position, InterviewFlow, InterviewType, InterviewStep, Candidate, Education, WorkExperience, Resume, ApplicationStatus, Application, InterviewResult, Interview), plus indexes and FK constraints.

Changes

Cohort / File(s) Summary
Database migration SQL
backend/prisma/migrations/20251115180951_db_avc/migration.sql
Creates 16 tables with primary keys, many indexes (unique and composite), and extensive foreign key constraints with specified ON DELETE / ON UPDATE behaviors (RESTRICT, CASCADE, SET NULL).
Prisma schema
backend/prisma/schema.prisma
Adds 16 Prisma models mirroring the SQL schema, defining fields, relations, indexes, defaults, timestamps, and cascade rules (notably candidate-related cascade deletes).
Migration lock file
backend/prisma/migrations/migration_lock.toml
Minor documentation/formatting text change (comment tweak and newline).
Documentation / prompts
prompts/prompts-AVC.md
New Markdown with multi-step prompts and two large Mermaid ERDs for analyzing/extending the recruitment schema, plus a migration failure example for troubleshooting.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • Pay special attention to foreign key delete/update behaviors across related models (Candidate → Education/WorkExperience/Resume, Application ↔ Position/Candidate/ApplicationStatus, Interview ↔ Application/Interviewer).
  • Verify consistency between migration.sql types, defaults, and indexes and the schema.prisma definitions to avoid runtime migration mismatches.
  • Review composite and unique indexes for correctness (e.g., unique candidate+position application constraint) and potential performance implications.
  • Inspect nullability and timestamp default usages to ensure application-layer expectations align.

Poem

🐇 I hopped through SQL fields bright and new,
Sixteen burrows where data grew,
Keys and links stitched neat and tight,
Resumes, interviews — morning to night,
A tiny rabbit cheers this schema view!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is in Spanish and translates to 'resolved AVC database exercise', which clearly describes that a database exercise was completed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
prompts/prompts-AVC.md (5)

3-3: Use proper Markdown heading syntax instead of emphasis.

Line 3 is semantically a heading but formatted as bold text. This affects document structure and accessibility. Use ## to create a proper heading.

-**Este ejercicio fue resuelto con Visual Studio Code con GitHub Copilot y Claude Sonnet 4**
+## Este ejercicio fue resuelto con Visual Studio Code con GitHub Copilot y Claude Sonnet 4

14-14: Reduce wordiness in the prompt.

"Take into account" is more verbose than necessary. Consider shorter alternatives like "Note that" or "Remember" to improve readability.

-Ok this is great answer, but I want to update the database in another way. I have to add new entities to the database. To do so I have an ERD in mermaid with the new entities and their relations. Take into account that this ERD is not normalized or indexed and I want you @workspace to update the Prisma schema in this way:
+Ok this is great answer, but I want to update the database in another way. I have to add new entities to the database. To do so I have an ERD in mermaid with the new entities and their relations. Note that this ERD is not normalized or indexed and I want you @workspace to update the Prisma schema in this way:

119-119: Correct Spanish spelling.

"Adjunto aqui" should be "Adjunto aquí" — the word "aquí" (here) requires an accent mark in Spanish.

-**NOTA: Adjunto aqui el script en mermaid que le pedí al LLM que creara. Un nuevo ERD de la nueva base de datos.**
+**NOTA: Adjunto aquí el script en mermaid que le pedí al LLM que creara. Un nuevo ERD de la nueva base de datos.**

341-357: Format the bare URL as a Markdown link.

Line 347 contains a bare URL that should be properly formatted as a Markdown link for better readability and accessibility.

-A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve
+A migration failed to apply. New migrations cannot be applied before the error is recovered from. Read more about how to resolve migration issues in a production database: [Prisma migration troubleshooting](https://pris.ly/d/migrate-resolve)

1-357: Documentation structure is solid; minor formatting and spelling improvements recommended.

The file effectively documents the exercise resolution process with clear progression through analysis, design, implementation, and troubleshooting. The two Mermaid ERD diagrams show thoughtful schema design with proper normalization. Static analysis flagged 4 minor issues (heading formatting, wordiness, Spanish spelling, bare URL) — all addressed above.

The changes suggested above are optional quality-of-life improvements that don't affect the educational value or clarity of the documentation.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c46eef and bb87b20.

📒 Files selected for processing (1)
  • prompts/prompts-AVC.md (1 hunks)
🧰 Additional context used
🪛 LanguageTool
prompts/prompts-AVC.md

[style] ~14-~14: ‘Take into account’ might be wordy. Consider a shorter alternative.
Context: ...h the new entities and their relations. Take into account that this ERD is not normalized or inde...

(EN_WORDINESS_PREMIUM_TAKE_INTO_ACCOUNT)


[grammar] ~119-~119: Ensure spelling is correct
Context: ...ew updated database?

**NOTA: Adjunto aqui el script en mermaid que le pedí al LLM...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🪛 markdownlint-cli2 (0.18.1)
prompts/prompts-AVC.md

3-3: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)


347-347: Bare URL used

(MD034, no-bare-urls)

@PetraZeta
Copy link
Contributor

💪 Fortalezas

  1. Modelado muy sólido y coherente
    Las entidades principales (Company, Position, Candidate, Application, Interview, etc.) están muy bien relacionadas y el diseño está claramente en 3FN, sin dependencias extrañas ni columnas “comodín”.

  2. Excelente alineación SQL ↔ Prisma
    El schema.prisma y el script SQL están prácticamente espejo: tipos, longitudes, índices, FKs y relaciones coinciden. Esto reduce muchísimo el riesgo de errores en migraciones y consultas.

  3. Buen enfoque en rendimiento e integridad
    Has creado índices en prácticamente todas las FKs y en columnas clave de filtrado (status, isVisible, createdAt, email, etc.). Además, usas correctamente ON DELETE CASCADE, SET NULL y RESTRICT según el tipo de relación.


🔧 Recomendaciones de mejora

  1. Añadir CHECKs para reglas de negocio clave
    Por ejemplo:

    • En Position, que salaryMin <= salaryMax.
    • En Interview, que el score esté dentro de un rango razonable (p. ej. 1–10).
    • Que las duraciones (duration, estimatedDuration) sean mayores que 0.
      Esto refuerza la calidad de datos directamente a nivel de base.
  2. Limpiar índices redundantes
    Hay casos donde tienes un índice UNIQUE y además un índice normal sobre la misma columna (Employee.email, Candidate.email, ApplicationStatus.orderIndex, InterviewResult.name). El índice único ya cubre las búsquedas, así que puedes eliminar los extras para simplificar y ahorrar recursos.

  3. Pensar en índices compuestos según las queries reales
    Por ejemplo, un índice en Position(companyId, status, isVisible) podría mejorar mucho el rendimiento en listados de vacantes filtradas por empresa y estado visible. No es obligatorio, pero sí una optimización interesante.


🚀 Mensaje final

El trabajo que hiciste en este módulo demuestra muy buen criterio de diseño, comprensión de Prisma + PostgreSQL y atención a detalles importantes como índices y reglas de integridad. Ya estás operando a un nivel muy cercano al de un DBA junior con foco en aplicaciones reales.

Sigue afinando con pequeños detalles (CHECKs, limpieza de índices, documentación de decisiones de cascadas) y tu modelo va a quedar espectacular. 💫
¡Muy buen trabajo, sigue así! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants