Refactor ActivityLog model, Flyway migrations, update dependency configurations - #51
Conversation
…tions, and update dependency configurations
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughReplaced explicit Flyway artifacts with Spring Boot's Flyway starter, set Hibernate DDL to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/resources/application.properties (1)
6-6: Keep Hibernate invalidateinstead ofnone.Spring Boot still calls
Flyway.migrate()on startup when Flyway is present, whilespring.jpa.hibernate.ddl-autoonly controls Hibernate’s schema action; Hibernate’sVALIDATEaction is schema validation, whereasnonedoes nothing. Switching this tononedrops the startup guardrail and defers mapping drift to runtime. (docs.spring.io)🔎 Minimal change
-spring.jpa.hibernate.ddl-auto=none +spring.jpa.hibernate.ddl-auto=validate🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/resources/application.properties` at line 6, Change the Hibernate schema action from "none" back to "validate" by updating the spring.jpa.hibernate.ddl-auto property value; locate the property spring.jpa.hibernate.ddl-auto in application.properties and set it to validate so Hibernate performs schema validation at startup (spring.jpa.hibernate.ddl-auto=validate) to retain the startup guardrail against mapping drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/resources/db/migration/V1__init.sql`:
- Around line 1-10: Add a b-tree index to support the read path used by
ActivityLogService (methods in
org/example/cyberwatch/features/activitylog/service/ActivityLogService.java that
fetch by ticket_id ordered by timestamp) so queries on activity_logs by
ticket_id ORDER BY timestamp are not forced to scan; create an index on
(ticket_id, timestamp) — preferably with timestamp DESC to match the ordering —
with a clear name (e.g., idx_activity_logs_ticket_timestamp) and include it in
the migration (either by updating the current migration or adding a new one) so
PostgreSQL will use the index for those lookups.
- Around line 78-85: The migration creates column s3key which doesn't match
Hibernate's default mapping for the TicketAttachment.s3Key field (expecting
s3_key); update the CREATE TABLE for ticket_attachment to rename the column from
s3key to s3_key so the database column name matches the entity's implicit
mapping and primary key/constraints remain unchanged.
---
Nitpick comments:
In `@src/main/resources/application.properties`:
- Line 6: Change the Hibernate schema action from "none" back to "validate" by
updating the spring.jpa.hibernate.ddl-auto property value; locate the property
spring.jpa.hibernate.ddl-auto in application.properties and set it to validate
so Hibernate performs schema validation at startup
(spring.jpa.hibernate.ddl-auto=validate) to retain the startup guardrail against
mapping drift.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2ebeadf9-79b5-4c23-95b6-f1a3c346b900
📒 Files selected for processing (6)
pom.xmlsrc/main/java/org/example/cyberwatch/config/DataInitializer.javasrc/main/java/org/example/cyberwatch/features/activitylog/model/ActivityLog.javasrc/main/java/org/example/cyberwatch/features/activitylog/service/ActivityLogService.javasrc/main/resources/application.propertiessrc/main/resources/db/migration/V1__init.sql
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/resources/db/migration/V1__init.sql`:
- Around line 27-35: Add indexes on the ticket foreign-key columns to avoid
future sequential scans and expensive FK checks: create a non-unique index on
comments.ticket_id (referencing the comments table and ticket_id column) and a
non-unique index on ticket_attachment.ticket_id (referencing the
ticket_attachment table and ticket_id column); ensure these index creations are
applied in a migration before or alongside V1__init.sql so reads and
deletes/updates on tickets use the indexes (note activity_logs already has the
appropriate composite index so no change needed there).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5c364b84-aca5-4996-a661-a2af6e93bde8
📒 Files selected for processing (1)
src/main/resources/db/migration/V1__init.sql
This pull request introduces several important changes to the database schema, dependency management, and data initialization logic. The main highlights include the addition of an initial Flyway migration script to set up all core tables and relationships, updates to Flyway and Spring Boot dependencies, improvements to the
ActivityLogmodel, and enhancements to the staff data initialization to include department information.Database schema and migration:
V1__init.sql) that creates all core tables (activity_logs,attachment,comments,employment_form,report_form,staff,ticket_attachment,tickets) and defines foreign key constraints and unique indexes to establish relationships and enforce data integrity.spring.jpa.hibernate.ddl-autofromvalidatetononeinapplication.propertiesto prevent Hibernate from managing schema changes, relying entirely on Flyway for schema management.Dependency and configuration updates:
pom.xmlto usespring-boot-starter-flywayandflyway-database-postgresqlfor better Flyway integration with PostgreSQL, replacing the previous directflyway-coredependency.Model and service improvements:
ActivityLogentity by adding an all-arguments constructor and a convenience constructor for easier instantiation, improving code clarity and reducing boilerplate. [1] [2]ActivityLogServiceto use the newActivityLogconstructor for logging comments.Data initialization enhancements:
createStaffmethod now accepts aDepartmentargument and sets it on theStaffentity. [1] [2]These changes collectively improve the maintainability, scalability, and clarity of the application's data layer and initialization process.
Summary by CodeRabbit
New Features
Refactor
Chores