Skip to content

✨ Add data field to Product#100

Merged
IamPekka058 merged 2 commits into
mainfrom
feature/update-database
Jun 3, 2026
Merged

✨ Add data field to Product#100
IamPekka058 merged 2 commits into
mainfrom
feature/update-database

Conversation

@Ruby11235
Copy link
Copy Markdown
Member

This PR adds the new field 'data' to the Product database.

@Ruby11235 Ruby11235 self-assigned this Jun 3, 2026
@Ruby11235 Ruby11235 added the ✨ Enhancement New feature or request label Jun 3, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Review Change Stack

Warning

Review limit reached

@Ruby11235, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 23 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 81687b09-4b14-42bf-8b29-91004743e975

📥 Commits

Reviewing files that changed from the base of the PR and between d64afc6 and 5af67e3.

📒 Files selected for processing (1)
  • ecoscan_backend/src/main/resources/db/migration/schema/V002__Product_Schema.sql

Walkthrough

The PR adds a data field to the Product domain model and persistence layer. The DTO and JPA entity are extended with the new field; the database schema gains a VARCHAR(2048) NOT NULL column; and test data seed inserts are updated to provide empty JSON payloads for all product rows.

Changes

Product data field expansion

Layer / File(s) Summary
Product domain model expansion
ecoscan_backend/src/main/java/com/rubberduckcrew/ecoscan_backend/products/dto/ProductDTO.java, ecoscan_backend/src/main/java/com/rubberduckcrew/ecoscan_backend/products/entity/Product.java
ProductDTO record signature gains a data parameter; Product entity declares a new @NotNull String data field positioned after description.
Database schema and test data
ecoscan_backend/src/main/resources/db/migration/schema/V002__Product_Schema.sql, ecoscan_backend/src/main/resources/db/migration/testdata/R__Products.sql
Schema migration adds a data column (VARCHAR(2048) NOT NULL) to the product table; bulk product insert is updated to include the data column with empty JSON ('{}') for each seeded row.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A field hops through the layers bright,
From DTO to Entity's might,
The schema spreads its VARCHAR arms,
With test data holding JSON charms,
Product data grows, all neat and right! 🌱

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a data field to the Product entity across the database schema, JPA entity, and DTO.
Description check ✅ Passed The description accurately states that the PR adds a new 'data' field to the Product database, which aligns with the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/update-database

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.

@Ruby11235 Ruby11235 force-pushed the feature/update-database branch from da16b51 to cd4a7ee Compare June 3, 2026 15:58
@Ruby11235 Ruby11235 force-pushed the feature/update-database branch from cd4a7ee to d64afc6 Compare June 3, 2026 16:06
@Ruby11235 Ruby11235 marked this pull request as ready for review June 3, 2026 16:07
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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@ecoscan_backend/src/main/java/com/rubberduckcrew/ecoscan_backend/products/entity/Product.java`:
- Line 33: The Product entity's data field is only annotated with `@NotNull` but
the DB schema constrains it to VARCHAR(2048) NOT NULL; update the Product class
so the data field mirrors the DB by adding a length constraint and non-null
column mapping (e.g., annotate the data field with `@Column`(length = 2048,
nullable = false) and a validation annotation like `@Size`(max = 2048)) similar to
the description field, ensuring oversized payloads are validated before
persistence.

In
`@ecoscan_backend/src/main/resources/db/migration/schema/V002__Product_Schema.sql`:
- Around line 1-2: The migration as written will fail on databases with existing
rows because it adds data as NOT NULL; change V002__Product_Schema.sql to be
backfill-safe by (1) adding the column as nullable (ALTER TABLE product ADD
COLUMN data VARCHAR(2048);), (2) backfilling existing rows (UPDATE product SET
data = '<appropriate-default>' WHERE data IS NULL; — choose e.g. '{}' or an
empty string consistent with your app), and then (3) enforce non-null (ALTER
TABLE product ALTER COLUMN data SET NOT NULL;). Reference the migration file
V002__Product_Schema.sql and the product.data column when making these
three-step changes.
🪄 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: 3ae919fd-3d25-4f7c-a5df-bbde4f1c1cb0

📥 Commits

Reviewing files that changed from the base of the PR and between 8d965d2 and d64afc6.

📒 Files selected for processing (4)
  • ecoscan_backend/src/main/java/com/rubberduckcrew/ecoscan_backend/products/dto/ProductDTO.java
  • ecoscan_backend/src/main/java/com/rubberduckcrew/ecoscan_backend/products/entity/Product.java
  • ecoscan_backend/src/main/resources/db/migration/schema/V002__Product_Schema.sql
  • ecoscan_backend/src/main/resources/db/migration/testdata/R__Products.sql

Comment thread ecoscan_backend/src/main/resources/db/migration/schema/V002__Product_Schema.sql Outdated
@IamPekka058 IamPekka058 self-requested a review June 3, 2026 18:04
@IamPekka058 IamPekka058 merged commit 3f70a93 into main Jun 3, 2026
10 checks passed
@IamPekka058 IamPekka058 deleted the feature/update-database branch June 3, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants