Skip to content

T2: Identity persistence + EF Core migration#59

Open
devin-ai-integration[bot] wants to merge 1 commit into
devin/identity-t1-domainfrom
devin/identity-t2-persistence
Open

T2: Identity persistence + EF Core migration#59
devin-ai-integration[bot] wants to merge 1 commit into
devin/identity-t1-domainfrom
devin/identity-t2-persistence

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the persistence layer for the Identity microservice:

  • IdentityDbContext configured with DbSet<AppUser> and DbSet<AppRole>, mapping to Users and Roles tables with unique indexes on UserName and Email
  • EF Core InitialCreate migration generated under Identity.Infrastructure/Data/Migrations/
  • Auto-migration at startup in Program.cs:
    using (var scope = app.Services.CreateScope())
    {
        var db = scope.ServiceProvider.GetRequiredService<IdentityDbContext>();
        db.Database.Migrate();
    }

Build passes (dotnet build -c Release); zero references to forbidden symbols. Migration verified against PostgreSQL (tables Users and Roles created).

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/0f07b7a8f1014aec962930431c54da9f
Requested by: @mbatchelor81


Open in Devin Review

- Configure IdentityDbContext with AppUser and AppRole entity mappings
- Add unique indexes on UserName and Email columns
- Generate InitialCreate migration (Users + Roles tables)
- Add auto-migration at startup in Program.cs
@mbatchelor81 mbatchelor81 self-assigned this Jun 26, 2026
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Open in Devin Review

Comment on lines +16 to +20
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<IdentityDbContext>();
db.Database.Migrate();
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🚩 Automatic migration on startup runs unconditionally in all environments

The db.Database.Migrate() call at src/Services/Identity/Identity.API/Program.cs:19 runs in all environments (dev, staging, production), unlike other services (Order, Customer) which have no auto-migration. In scaled-out production deployments, multiple instances will attempt to migrate concurrently. PostgreSQL + EF Core handle this safely via advisory locks, so it won't corrupt data, but it adds startup latency and is a pattern divergence from other services. If this is intentional for the T2 persistence task, consider gating behind IsDevelopment() or an environment variable before merging to production branches.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is intentional per the T2 task specification — the auto-migration placement was explicitly required. PostgreSQL + EF Core advisory locks make concurrent startup safe. Gating behind an environment check can be considered in a follow-up if needed before production deployment.

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.

1 participant