T2: Identity persistence + EF Core migration#59
T2: Identity persistence + EF Core migration#59devin-ai-integration[bot] wants to merge 1 commit into
Conversation
- 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
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
| using (var scope = app.Services.CreateScope()) | ||
| { | ||
| var db = scope.ServiceProvider.GetRequiredService<IdentityDbContext>(); | ||
| db.Database.Migrate(); | ||
| } |
There was a problem hiding this comment.
🚩 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.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
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.
Summary
Implements the persistence layer for the Identity microservice:
IdentityDbContextconfigured withDbSet<AppUser>andDbSet<AppRole>, mapping toUsersandRolestables with unique indexes onUserNameandEmailInitialCreatemigration generated underIdentity.Infrastructure/Data/Migrations/Program.cs:Build passes (
dotnet build -c Release); zero references to forbidden symbols. Migration verified against PostgreSQL (tablesUsersandRolescreated).Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/0f07b7a8f1014aec962930431c54da9f
Requested by: @mbatchelor81