From cc589b13d073bd8d4133838d1072d2666c2b9413 Mon Sep 17 00:00:00 2001 From: Gulum Date: Fri, 5 Jun 2026 23:37:21 +0200 Subject: [PATCH] ARCH-2: fresh Npgsql initial migration uuid keys, text columns, Gender persisted as text via EnumToStringConverter, Litter.Date as timestamptz. Replaces deleted SqlServer initialCreate (no prod data). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../20260605213640_InitialCreate.Designer.cs | 134 ++++++++++++++++++ .../20260605213640_InitialCreate.cs | 121 ++++++++++++++++ .../ApplicationContextModelSnapshot.cs | 131 +++++++++++++++++ 3 files changed, 386 insertions(+) create mode 100644 GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.Designer.cs create mode 100644 GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.cs create mode 100644 GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs diff --git a/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.Designer.cs b/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.Designer.cs new file mode 100644 index 0000000..4d61ec0 --- /dev/null +++ b/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.Designer.cs @@ -0,0 +1,134 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace GerbilManagerWebAPI.Migrations +{ + [DbContext(typeof(ApplicationContext))] + [Migration("20260605213640_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Breeder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Breeders", (string)null); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BreederId") + .HasColumnType("uuid"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("text"); + + b.Property("LitterId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BreederId"); + + b.HasIndex("LitterId"); + + b.ToTable("Gerbils", (string)null); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("FatherId") + .HasColumnType("uuid"); + + b.Property("MotherId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Strength") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FatherId"); + + b.HasIndex("MotherId"); + + b.ToTable("Litters", (string)null); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Breeder", "Breeder") + .WithMany() + .HasForeignKey("BreederId"); + + b.HasOne("GerbilManagerWebAPI.Models.Litter", "Litter") + .WithMany() + .HasForeignKey("LitterId"); + + b.Navigation("Breeder"); + + b.Navigation("Litter"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father") + .WithMany() + .HasForeignKey("FatherId"); + + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother") + .WithMany() + .HasForeignKey("MotherId"); + + b.Navigation("Father"); + + b.Navigation("Mother"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.cs b/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.cs new file mode 100644 index 0000000..02c6b16 --- /dev/null +++ b/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.cs @@ -0,0 +1,121 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace GerbilManagerWebAPI.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Breeders", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Breeders", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Gerbils", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Gender = table.Column(type: "text", nullable: false), + LitterId = table.Column(type: "uuid", nullable: true), + BreederId = table.Column(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Gerbils", x => x.Id); + table.ForeignKey( + name: "FK_Gerbils_Breeders_BreederId", + column: x => x.BreederId, + principalTable: "Breeders", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Litters", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Date = table.Column(type: "timestamp with time zone", nullable: false), + Strength = table.Column(type: "integer", nullable: true), + FatherId = table.Column(type: "uuid", nullable: true), + MotherId = table.Column(type: "uuid", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Litters", x => x.Id); + table.ForeignKey( + name: "FK_Litters_Gerbils_FatherId", + column: x => x.FatherId, + principalTable: "Gerbils", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Litters_Gerbils_MotherId", + column: x => x.MotherId, + principalTable: "Gerbils", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Gerbils_BreederId", + table: "Gerbils", + column: "BreederId"); + + migrationBuilder.CreateIndex( + name: "IX_Gerbils_LitterId", + table: "Gerbils", + column: "LitterId"); + + migrationBuilder.CreateIndex( + name: "IX_Litters_FatherId", + table: "Litters", + column: "FatherId"); + + migrationBuilder.CreateIndex( + name: "IX_Litters_MotherId", + table: "Litters", + column: "MotherId"); + + migrationBuilder.AddForeignKey( + name: "FK_Gerbils_Litters_LitterId", + table: "Gerbils", + column: "LitterId", + principalTable: "Litters", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Gerbils_Breeders_BreederId", + table: "Gerbils"); + + migrationBuilder.DropForeignKey( + name: "FK_Gerbils_Litters_LitterId", + table: "Gerbils"); + + migrationBuilder.DropTable( + name: "Breeders"); + + migrationBuilder.DropTable( + name: "Litters"); + + migrationBuilder.DropTable( + name: "Gerbils"); + } + } +} diff --git a/GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs b/GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs new file mode 100644 index 0000000..95e0d3c --- /dev/null +++ b/GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs @@ -0,0 +1,131 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace GerbilManagerWebAPI.Migrations +{ + [DbContext(typeof(ApplicationContext))] + partial class ApplicationContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "10.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Breeder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Breeders", (string)null); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BreederId") + .HasColumnType("uuid"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("text"); + + b.Property("LitterId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("BreederId"); + + b.HasIndex("LitterId"); + + b.ToTable("Gerbils", (string)null); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("FatherId") + .HasColumnType("uuid"); + + b.Property("MotherId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Strength") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FatherId"); + + b.HasIndex("MotherId"); + + b.ToTable("Litters", (string)null); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Breeder", "Breeder") + .WithMany() + .HasForeignKey("BreederId"); + + b.HasOne("GerbilManagerWebAPI.Models.Litter", "Litter") + .WithMany() + .HasForeignKey("LitterId"); + + b.Navigation("Breeder"); + + b.Navigation("Litter"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father") + .WithMany() + .HasForeignKey("FatherId"); + + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother") + .WithMany() + .HasForeignKey("MotherId"); + + b.Navigation("Father"); + + b.Navigation("Mother"); + }); +#pragma warning restore 612, 618 + } + } +}