-
Notifications
You must be signed in to change notification settings - Fork 0
T2: Identity persistence + EF Core migration #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
1
commit into
devin/identity-t1-domain
Choose a base branch
from
devin/identity-t2-persistence
base: devin/identity-t1-domain
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...Identity/Identity.Infrastructure/Data/Migrations/20260626044104_InitialCreate.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
...Services/Identity/Identity.Infrastructure/Data/Migrations/20260626044104_InitialCreate.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| using System; | ||
| using Microsoft.EntityFrameworkCore.Migrations; | ||
|
|
||
| #nullable disable | ||
|
|
||
| namespace Identity.Infrastructure.Data.Migrations | ||
| { | ||
| /// <inheritdoc /> | ||
| public partial class InitialCreate : Migration | ||
| { | ||
| /// <inheritdoc /> | ||
| protected override void Up(MigrationBuilder migrationBuilder) | ||
| { | ||
| migrationBuilder.CreateTable( | ||
| name: "Roles", | ||
| columns: table => new | ||
| { | ||
| Id = table.Column<Guid>(type: "uuid", nullable: false), | ||
| Name = table.Column<string>(type: "text", nullable: false), | ||
| Description = table.Column<string>(type: "text", nullable: true) | ||
| }, | ||
| constraints: table => | ||
| { | ||
| table.PrimaryKey("PK_Roles", x => x.Id); | ||
| }); | ||
|
|
||
| migrationBuilder.CreateTable( | ||
| name: "Users", | ||
| columns: table => new | ||
| { | ||
| Id = table.Column<Guid>(type: "uuid", nullable: false), | ||
| UserName = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), | ||
| Email = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false), | ||
| PasswordHash = table.Column<string>(type: "text", nullable: false), | ||
| FullName = table.Column<string>(type: "text", nullable: true), | ||
| JobTitle = table.Column<string>(type: "text", nullable: true), | ||
| IsEnabled = table.Column<bool>(type: "boolean", nullable: false), | ||
| CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false), | ||
| UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false) | ||
| }, | ||
| constraints: table => | ||
| { | ||
| table.PrimaryKey("PK_Users", x => x.Id); | ||
| }); | ||
|
|
||
| migrationBuilder.CreateIndex( | ||
| name: "IX_Users_Email", | ||
| table: "Users", | ||
| column: "Email", | ||
| unique: true); | ||
|
|
||
| migrationBuilder.CreateIndex( | ||
| name: "IX_Users_UserName", | ||
| table: "Users", | ||
| column: "UserName", | ||
| unique: true); | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| protected override void Down(MigrationBuilder migrationBuilder) | ||
| { | ||
| migrationBuilder.DropTable( | ||
| name: "Roles"); | ||
|
|
||
| migrationBuilder.DropTable( | ||
| name: "Users"); | ||
| } | ||
| } | ||
| } |
91 changes: 91 additions & 0 deletions
91
...rvices/Identity/Identity.Infrastructure/Data/Migrations/IdentityDbContextModelSnapshot.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // <auto-generated /> | ||
| using System; | ||
| using Identity.Infrastructure.Data; | ||
| using Microsoft.EntityFrameworkCore; | ||
| using Microsoft.EntityFrameworkCore.Infrastructure; | ||
| using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
| using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; | ||
|
|
||
| #nullable disable | ||
|
|
||
| namespace Identity.Infrastructure.Data.Migrations | ||
| { | ||
| [DbContext(typeof(IdentityDbContext))] | ||
| partial class IdentityDbContextModelSnapshot : ModelSnapshot | ||
| { | ||
| protected override void BuildModel(ModelBuilder modelBuilder) | ||
| { | ||
| #pragma warning disable 612, 618 | ||
| modelBuilder | ||
| .HasAnnotation("ProductVersion", "10.0.9") | ||
| .HasAnnotation("Relational:MaxIdentifierLength", 63); | ||
|
|
||
| NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); | ||
|
|
||
| modelBuilder.Entity("Identity.Domain.Entities.AppRole", b => | ||
| { | ||
| b.Property<Guid>("Id") | ||
| .ValueGeneratedOnAdd() | ||
| .HasColumnType("uuid"); | ||
|
|
||
| b.Property<string>("Description") | ||
| .HasColumnType("text"); | ||
|
|
||
| b.Property<string>("Name") | ||
| .IsRequired() | ||
| .HasColumnType("text"); | ||
|
|
||
| b.HasKey("Id"); | ||
|
|
||
| b.ToTable("Roles", (string)null); | ||
| }); | ||
|
|
||
| modelBuilder.Entity("Identity.Domain.Entities.AppUser", b => | ||
| { | ||
| b.Property<Guid>("Id") | ||
| .ValueGeneratedOnAdd() | ||
| .HasColumnType("uuid"); | ||
|
|
||
| b.Property<DateTime>("CreatedAt") | ||
| .HasColumnType("timestamp with time zone"); | ||
|
|
||
| b.Property<string>("Email") | ||
| .IsRequired() | ||
| .HasMaxLength(100) | ||
| .HasColumnType("character varying(100)"); | ||
|
|
||
| b.Property<string>("FullName") | ||
| .HasColumnType("text"); | ||
|
|
||
| b.Property<bool>("IsEnabled") | ||
| .HasColumnType("boolean"); | ||
|
|
||
| b.Property<string>("JobTitle") | ||
| .HasColumnType("text"); | ||
|
|
||
| b.Property<string>("PasswordHash") | ||
| .IsRequired() | ||
| .HasColumnType("text"); | ||
|
|
||
| b.Property<DateTime>("UpdatedAt") | ||
| .HasColumnType("timestamp with time zone"); | ||
|
|
||
| b.Property<string>("UserName") | ||
| .IsRequired() | ||
| .HasMaxLength(100) | ||
| .HasColumnType("character varying(100)"); | ||
|
|
||
| b.HasKey("Id"); | ||
|
|
||
| b.HasIndex("Email") | ||
| .IsUnique(); | ||
|
|
||
| b.HasIndex("UserName") | ||
| .IsUnique(); | ||
|
|
||
| b.ToTable("Users", (string)null); | ||
| }); | ||
| #pragma warning restore 612, 618 | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 atsrc/Services/Identity/Identity.API/Program.cs:19runs 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 behindIsDevelopment()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.
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.