Skip to content

Abc/initial database tables#5

Merged
aristachauhan merged 7 commits into
mainfrom
abc/initial-database-tables
Jun 29, 2026
Merged

Abc/initial database tables#5
aristachauhan merged 7 commits into
mainfrom
abc/initial-database-tables

Conversation

@aristachauhan

@aristachauhan aristachauhan commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • Added support for managing application users with identity, profile, activity, and audit information.
    • Introduced database setup for the new user records and related indexing.
  • Chores

    • Renamed the app/project metadata to leaves.
    • Updated local development container labels and database helper commands to match the new project name.
  • Refactor

    • Removed the sample weather data feature and its related API surface.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

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

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

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

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f21f8f43-9ba1-44e3-a2e3-422c76340a3e

📥 Commits

Reviewing files that changed from the base of the PR and between 7fdba2a and ec077e2.

📒 Files selected for processing (5)
  • server.core/Data/AppDbContext.cs
  • server.core/Domain/AppUser.cs
  • server.core/Migrations/20260626225422_AppUser.Designer.cs
  • server.core/Migrations/20260626225422_AppUser.cs
  • server.core/Migrations/AppDbContextModelSnapshot.cs
📝 Walkthrough

Walkthrough

This PR renames the workspace/package to leaves, adds the AppUser EF Core model and migration, wires save-time audit normalization in AppDbContext, and removes the WeatherForecast controller and development seed path.

Changes

Project identity update

Layer / File(s) Summary
Project name update
.devcontainer/devcontainer.json, package.json
Updates the devcontainer display name, package name, and database helper scripts to use leaves and leaves_devcontainer.

AppUser schema replacement

Layer / File(s) Summary
AppUser contract and mapping
server.core/Domain/AppUser.cs, server.core/Data/AppDbContext.cs
Adds AppUser, exposes AppUsers, and wires AppUser.Configure(...) into model creation.
Audit stamping
server.core/Data/AppDbContext.cs
Overrides SaveChanges/SaveChangesAsync, normalizes IamId/EmployeeId, and stamps CreatedUtc/UpdatedUtc on AppUser entries.
AppUser migration and snapshot
server.core/Migrations/20260626222952_AppUser.cs, server.core/Migrations/20260626222952_AppUser.Designer.cs, server.core/Migrations/AppDbContextModelSnapshot.cs
Creates the AppUser table, drops it on rollback, and updates the snapshot and generated model metadata.
WeatherForecast cleanup
server.core/Domain/Weather.cs, server.core/Data/DbInitializer.cs, server/Controllers/WeatherForecastController.cs
Removes the WeatherForecast model, disables development seeding, and deletes the controller that queried recent forecasts.

Sequence Diagram(s)

sequenceDiagram
  participant AppDbContext
  participant ChangeTracker
  participant AppUser
  participant Database
  AppDbContext->>ChangeTracker: enumerate tracked AppUser entries
  ChangeTracker-->>AppDbContext: added and modified entries
  AppDbContext->>AppUser: trim IamId and EmployeeId
  AppDbContext->>AppUser: stamp CreatedUtc and UpdatedUtc
  AppDbContext->>Database: base SaveChanges persists AppUser rows
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

ᕱ⑅ᕱ
I hopped to leaves with a shiny new name,
AppUser stamped time in the EF game.
I twitched my nose at the old forecast hue,
Then binkied away with a happy “boop!” or two.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is relevant and reasonably describes the main change: introducing initial database tables.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch abc/initial-database-tables

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.

@aristachauhan
aristachauhan marked this pull request as ready for review June 26, 2026 20:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 `@server.core/Data/AppDbContext.cs`:
- Around line 12-34: AppUser’s audit timestamps are still caller-managed, so
inserts can save default DateTime values and UpdatedUtc can become stale. Update
AppDbContext’s model configuration for AppUser to give CreatedUtc a
database-generated insert default and ensure UpdatedUtc is refreshed on every
save via SaveChanges or an interceptor. Use the AppUser entity mapping in
OnModelCreating and the save pipeline hook that persists changes to centralize
this behavior.
- Around line 22-30: The filtered unique indexes on IamId and EmployeeId still
treat blank padded values as non-null, so repeated “missing” IDs can violate
uniqueness. Update the AppDbContext configuration around the IamId and
EmployeeId indexes to also exclude blank/whitespace values in the filter, or
normalize those properties to null before saving. Use the existing HasIndex
setup for AppUser and, if needed, add save-time normalization in the
context/entity pipeline so optional IDs don’t reach the database as padded
blanks.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: 634751ee-4cef-4f47-86b7-35ef4fb596b1

📥 Commits

Reviewing files that changed from the base of the PR and between 9b30064 and ba0bf98.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (13)
  • .devcontainer/devcontainer.json
  • package.json
  • server.core/Data/AppDbContext.cs
  • server.core/Data/DbInitializer.cs
  • server.core/Domain/AppUser.cs
  • server.core/Domain/Weather.cs
  • server.core/Migrations/20251007172808_WeatherSample.Designer.cs
  • server.core/Migrations/20251007172808_WeatherSample.cs
  • server.core/Migrations/20260626194228_InitialCreate.Designer.cs
  • server.core/Migrations/20260626194228_InitialCreate.cs
  • server.core/Migrations/AppDbContextModelSnapshot.cs
  • server/Controllers/WeatherForecastController.cs
  • tests/server.tests/Controllers/WeatherForecastControllerTests.cs
💤 Files with no reviewable changes (5)
  • server.core/Migrations/20251007172808_WeatherSample.cs
  • server.core/Migrations/20251007172808_WeatherSample.Designer.cs
  • tests/server.tests/Controllers/WeatherForecastControllerTests.cs
  • server/Controllers/WeatherForecastController.cs
  • server.core/Domain/Weather.cs

Comment thread server.core/Data/AppDbContext.cs Outdated
Comment thread server.core/Data/AppDbContext.cs Outdated
Comment thread server.core/Domain/AppUser.cs Outdated
Comment thread server.core/Domain/AppUser.cs Outdated
Comment thread server.core/Data/AppDbContext.cs Outdated
Comment thread server.core/Domain/AppUser.cs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
server.core/Domain/AppUser.cs (1)

35-37: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Stamp FirstLoginUtc on insert
FirstLoginUtc has no default or insert-time stamp, so a new AppUser can persist 0001-01-01 unless every caller sets it manually. Stamp it on add or give it a DB default.

🤖 Prompt for 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.

In `@server.core/Domain/AppUser.cs` around lines 35 - 37, The
AppUser.FirstLoginUtc field is required but currently has no automatic
insert-time value, so new AppUser rows can persist the default DateTime. Update
the AppUser model or its persistence setup to stamp FirstLoginUtc when the
entity is added, or configure a database default, and make sure the fix is
applied through the AppUser mapping/configuration rather than relying on every
caller to set it manually.
🧹 Nitpick comments (2)
server.core/Data/AppDbContext.cs (1)

31-56: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Optional: scope and immutability of audit stamping.

Two minor observations on StampAuditFields:

  • It's hard-coded to AppUser. As more audited entities arrive, consider an IAuditable marker interface and iterate ChangeTracker.Entries<IAuditable>() so this logic stays single-sourced.
  • On Modified, CreatedUtc is left writable, so a caller that mutates it will persist the change. If CreatedUtc should be immutable, mark its property as unmodified for Modified entries.

Both are deferrable.

🤖 Prompt for 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.

In `@server.core/Data/AppDbContext.cs` around lines 31 - 56, The audit stamping in
StampAuditFields is currently scoped only to AppUser and allows CreatedUtc to
remain writable on modified entities. Consider broadening the loop to entries of
a shared auditable contract such as IAuditable so the logic applies to all
audited entities, and in the Modified branch explicitly prevent CreatedUtc from
being persisted if it should be immutable by marking that property as unmodified
while still updating UpdatedUtc.
server.core/Domain/AppUser.cs (1)

66-69: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Remove the redundant IamId filter from the unique index. IamId is non-nullable, so HasFilter("[IamId] IS NOT NULL") adds no value and turns the index into a filtered one, which adds SQL Server DML SET-option requirements for no benefit. Update server.core/Migrations/20260626222952_AppUser.cs to match.

♻️ Proposed change
         entity.HasIndex(e => e.IamId)
             .IsUnique()
-            .HasFilter("[IamId] IS NOT NULL")
             .HasDatabaseName("UX_AppUser_IamId");
🤖 Prompt for 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.

In `@server.core/Domain/AppUser.cs` around lines 66 - 69, Remove the redundant
filter from the unique index on AppUser.IamId in the AppUser entity
configuration; in the HasIndex(e => e.IamId) chain, keep the unique index and
database name but drop the HasFilter call since IamId is non-nullable. Then
update the AppUser migration so its index definition matches the model
configuration and no longer creates a filtered index.
🤖 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.

Outside diff comments:
In `@server.core/Domain/AppUser.cs`:
- Around line 35-37: The AppUser.FirstLoginUtc field is required but currently
has no automatic insert-time value, so new AppUser rows can persist the default
DateTime. Update the AppUser model or its persistence setup to stamp
FirstLoginUtc when the entity is added, or configure a database default, and
make sure the fix is applied through the AppUser mapping/configuration rather
than relying on every caller to set it manually.

---

Nitpick comments:
In `@server.core/Data/AppDbContext.cs`:
- Around line 31-56: The audit stamping in StampAuditFields is currently scoped
only to AppUser and allows CreatedUtc to remain writable on modified entities.
Consider broadening the loop to entries of a shared auditable contract such as
IAuditable so the logic applies to all audited entities, and in the Modified
branch explicitly prevent CreatedUtc from being persisted if it should be
immutable by marking that property as unmodified while still updating
UpdatedUtc.

In `@server.core/Domain/AppUser.cs`:
- Around line 66-69: Remove the redundant filter from the unique index on
AppUser.IamId in the AppUser entity configuration; in the HasIndex(e => e.IamId)
chain, keep the unique index and database name but drop the HasFilter call since
IamId is non-nullable. Then update the AppUser migration so its index definition
matches the model configuration and no longer creates a filtered index.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fe91d2d9-6d61-448a-bb63-7146001731c2

📥 Commits

Reviewing files that changed from the base of the PR and between ba0bf98 and 7fdba2a.

📒 Files selected for processing (5)
  • server.core/Data/AppDbContext.cs
  • server.core/Domain/AppUser.cs
  • server.core/Migrations/20260626222952_AppUser.Designer.cs
  • server.core/Migrations/20260626222952_AppUser.cs
  • server.core/Migrations/AppDbContextModelSnapshot.cs
✅ Files skipped from review due to trivial changes (2)
  • server.core/Migrations/20260626222952_AppUser.Designer.cs
  • server.core/Migrations/AppDbContextModelSnapshot.cs

@jSylvestre jSylvestre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Created a new local database for me without any issues.

@aristachauhan
aristachauhan merged commit d962dc7 into main Jun 29, 2026
4 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jul 6, 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.

3 participants