Skip to content

Feature/db registry#6

Merged
gvaguirres merged 4 commits intomainfrom
feature/db-registry
Apr 2, 2026
Merged

Feature/db registry#6
gvaguirres merged 4 commits intomainfrom
feature/db-registry

Conversation

@MartinStenhagen
Copy link
Copy Markdown
Contributor

@MartinStenhagen MartinStenhagen commented Apr 2, 2026

Added registry to db and db-cleanup

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new registry management feature with validation mechanisms to ensure data consistency and integrity for registry codes and names.
  • Chores

    • Enhanced backend infrastructure with validation support libraries.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

📝 Walkthrough

Walkthrough

This PR introduces a new Registry entity and supporting database infrastructure. A Spring Boot validation dependency is added to pom.xml. A new JPA entity class Registry is created with id, name, code, and createdAt fields. An existing app_user table migration is removed, and a new registry table migration is added with unique and pattern-matching constraints.

Changes

Cohort / File(s) Summary
Dependencies
pom.xml
Added Spring Boot validation starter dependency for bean validation support.
Registry Entity
src/main/java/backendlab/team4you/registry/Registry.java
New JPA entity with auto-generated id, validated name (max 100 chars), and code (pattern: [A-Z]{2}) fields, plus immutable createdAt timestamp. Includes protected no-arg and public constructors.
Database Migrations
src/main/resources/db/migration/V1__init_schema.sql, src/main/resources/db/migration/V2__registry.sql
Removed app_user table schema; added new registry table with unique constraints on name and code, and regex validation on code field (^[A-Z]{2}$).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A new Registry hops into being,
With codes that must be pristine and clean,
Two letters bold, a pattern so neat,
Validation constraints make schemas complete! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Feature/db registry' is partially related to the changeset, referring to a real aspect of the changes (adding a registry database feature), but uses a vague, non-descriptive format with a branch-like naming convention rather than a clear summary of the main change. Revise the title to be more descriptive and concise, e.g., 'Add registry table and entity with validation' or 'Implement registry database schema and JPA entity'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/db-registry

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
Copy Markdown

@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.

🧹 Nitpick comments (2)
src/main/java/backendlab/team4you/registry/Registry.java (2)

23-24: Consider adding a getter for createdAt.

The createdAt field is mapped but has no accessor method, unlike id, name, and code. If this timestamp needs to be exposed (e.g., for API responses or auditing), add a getter. If it's intentionally hidden, this is fine as-is.

♻️ Proposed addition
     public String getCode() {
         return code;
     }
+
+    public LocalDateTime getCreatedAt() {
+        return createdAt;
+    }
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/backendlab/team4you/registry/Registry.java` around lines 23 -
24, The Registry class declares a mapped field createdAt but lacks an accessor;
add a public getter method public LocalDateTime getCreatedAt() to Registry so
callers (e.g., serializers, services) can read the timestamp; implement it
alongside the existing getters for id/name/code and ensure its return type is
java.time.LocalDateTime and it simply returns the createdAt field.

23-24: Note: createdAt will be null until entity is refreshed.

With insertable = false, JPA won't include createdAt in the INSERT statement (relying on the DB default), but it also won't automatically read back the generated value. After persist(), the field remains null until you call EntityManager.refresh() or re-fetch the entity.

If you need access to createdAt immediately after saving, consider either:

  1. Calling refresh() after persist
  2. Using @PostLoad / @PostPersist callbacks
  3. Setting the value manually in the constructor (as done in UserEntity)

If createdAt is only needed for DB queries or audit purposes, the current approach is fine.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/backendlab/team4you/registry/Registry.java` around lines 23 -
24, The createdAt field in class Registry is annotated with `@Column`(...,
insertable = false) so JPA will not populate it after persist and it stays null;
to ensure createdAt is available immediately after saving, choose one approach
and implement it: either remove insertable = false so JPA writes/reads the
value, or keep DB default and call EntityManager.refresh(registry) after persist
where you save Registry, or add a lifecycle callback (e.g., `@PostPersist` method
in Registry to set createdAt from the DB or set the timestamp in the
constructor/Builder like UserEntity); update the Registry.createdAt handling
accordingly and adjust the persist call site to call refresh if you keep
insertable = false.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/main/java/backendlab/team4you/registry/Registry.java`:
- Around line 23-24: The Registry class declares a mapped field createdAt but
lacks an accessor; add a public getter method public LocalDateTime
getCreatedAt() to Registry so callers (e.g., serializers, services) can read the
timestamp; implement it alongside the existing getters for id/name/code and
ensure its return type is java.time.LocalDateTime and it simply returns the
createdAt field.
- Around line 23-24: The createdAt field in class Registry is annotated with
`@Column`(..., insertable = false) so JPA will not populate it after persist and
it stays null; to ensure createdAt is available immediately after saving, choose
one approach and implement it: either remove insertable = false so JPA
writes/reads the value, or keep DB default and call
EntityManager.refresh(registry) after persist where you save Registry, or add a
lifecycle callback (e.g., `@PostPersist` method in Registry to set createdAt from
the DB or set the timestamp in the constructor/Builder like UserEntity); update
the Registry.createdAt handling accordingly and adjust the persist call site to
call refresh if you keep insertable = false.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7d78a8c8-14ca-48b0-bacd-ae7485cd3cee

📥 Commits

Reviewing files that changed from the base of the PR and between c334ba1 and 1c3c9bc.

📒 Files selected for processing (5)
  • pom.xml
  • src/main/java/backendlab/team4you/registry/Registry.java
  • src/main/resources/db/migration/V1__init_schema.sql
  • src/main/resources/db/migration/V1__initial_schema_and_webauthn.sql
  • src/main/resources/db/migration/V2__registry.sql
💤 Files with no reviewable changes (1)
  • src/main/resources/db/migration/V1__init_schema.sql

@gvaguirres gvaguirres merged commit 28feca4 into main Apr 2, 2026
2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Apr 2, 2026
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