diff --git a/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.Designer.cs b/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.Designer.cs deleted file mode 100644 index 4d61ec0..0000000 --- a/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.Designer.cs +++ /dev/null @@ -1,134 +0,0 @@ -// -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 deleted file mode 100644 index 02c6b16..0000000 --- a/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.cs +++ /dev/null @@ -1,121 +0,0 @@ -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/20260605225413_InitialCreate.Designer.cs b/GerbilManagerWebAPI/Migrations/20260605225413_InitialCreate.Designer.cs new file mode 100644 index 0000000..933eafd --- /dev/null +++ b/GerbilManagerWebAPI/Migrations/20260605225413_InitialCreate.Designer.cs @@ -0,0 +1,500 @@ +// +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("20260605225413_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.ColorVariety", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CanonicalGenotype") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ColorVarieties"); + + b.HasData( + new + { + Id = new Guid("00000000-0000-0000-0000-000000000001"), + CanonicalGenotype = "AA chch DD EE GG pp spsp rere", + Name = "Pink Eyed White (PEW)", + SortOrder = 0 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000002"), + CanonicalGenotype = "aa chch DD EE GG PP spsp rere", + Name = "Hermelin", + SortOrder = 1 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000003"), + CanonicalGenotype = "AA chch DD EE GG PP spsp rere", + Name = "Himalaya", + SortOrder = 2 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000004"), + CanonicalGenotype = "aa cchmcchm DD EE gg PP spsp rere", + Name = "Zobel", + SortOrder = 3 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000005"), + CanonicalGenotype = "AA CC DD efef GG PP spsp rere", + Name = "Schwarzschimmel", + SortOrder = 4 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000006"), + CanonicalGenotype = "AA CC DD efef GG pp spsp rere", + Name = "Rotaugenschimmel", + SortOrder = 5 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000007"), + CanonicalGenotype = "AA CC DD EE GG PP spsp rere", + Name = "Agouti", + SortOrder = 6 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000008"), + CanonicalGenotype = "aa CC DD EE GG PP spsp rere", + Name = "Schwarz", + SortOrder = 7 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000009"), + CanonicalGenotype = "AA CC DD EE gg PP spsp rere", + Name = "Silberagouti", + SortOrder = 8 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000010"), + CanonicalGenotype = "aa CC DD EE gg PP spsp rere", + Name = "Anthrazit", + SortOrder = 9 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000011"), + CanonicalGenotype = "AA CC DD ee GG PP spsp rere", + Name = "Algierfuchs", + SortOrder = 10 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000012"), + CanonicalGenotype = "aa CC dd EE GG PP spsp rere", + Name = "Blau", + SortOrder = 11 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000013"), + CanonicalGenotype = "AA CC DD EE GG pp spsp rere", + Name = "Gold", + SortOrder = 12 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000014"), + CanonicalGenotype = "aa CC DD EE GG pp spsp rere", + Name = "Platin", + SortOrder = 13 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000015"), + CanonicalGenotype = "AA CC DD ee GG pp spsp rere", + Name = "Goldfuchs", + SortOrder = 14 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000016"), + CanonicalGenotype = "aa CC DD ee GG pp spsp rere", + Name = "Rotfuchs", + SortOrder = 15 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000017"), + CanonicalGenotype = "AA CC dd EE GG pp spsp rere", + Name = "dd Gold", + SortOrder = 16 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000018"), + CanonicalGenotype = "aa CC dd EE GG pp spsp rere", + Name = "dd Platin", + SortOrder = 17 + }); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContactInfo") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Contacts"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Enclosure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Enclosures"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CauseOfDeath") + .HasColumnType("text"); + + b.Property("ColorVarietyId") + .HasColumnType("uuid"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("DateOfDeath") + .HasColumnType("date"); + + b.Property("EnclosureId") + .HasColumnType("uuid"); + + b.Property("ExternalRef") + .HasColumnType("text"); + + b.Property("Gender") + .IsRequired() + .HasColumnType("text"); + + b.Property("Genotype") + .HasColumnType("text"); + + b.Property("GoHomeDate") + .HasColumnType("date"); + + b.Property("ImportSource") + .HasColumnType("text"); + + b.Property("LitterId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("OriginContactId") + .HasColumnType("uuid"); + + b.Property("ReceiverContactId") + .HasColumnType("uuid"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ColorVarietyId"); + + b.HasIndex("EnclosureId"); + + b.HasIndex("LitterId"); + + b.HasIndex("OriginContactId"); + + b.HasIndex("ReceiverContactId"); + + b.ToTable("Gerbils"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.GerbilPhoto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Caption") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("GerbilId") + .HasColumnType("uuid"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GerbilId"); + + b.ToTable("GerbilPhotos"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.HealthRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("GerbilId") + .HasColumnType("uuid"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Veterinarian") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("GerbilId"); + + b.ToTable("HealthRecords"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("ExpectedGoHomeDate") + .HasColumnType("date"); + + b.Property("FatherId") + .HasColumnType("uuid"); + + b.Property("MotherId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("TotalBorn") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FatherId"); + + b.HasIndex("MotherId"); + + b.ToTable("Litters"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.WeightRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("GerbilId") + .HasColumnType("uuid"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("WeightGrams") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GerbilId"); + + b.ToTable("WeightRecords"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => + { + b.HasOne("GerbilManagerWebAPI.Models.ColorVariety", "ColorVariety") + .WithMany() + .HasForeignKey("ColorVarietyId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("GerbilManagerWebAPI.Models.Enclosure", "Enclosure") + .WithMany("Gerbils") + .HasForeignKey("EnclosureId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("GerbilManagerWebAPI.Models.Litter", "Litter") + .WithMany() + .HasForeignKey("LitterId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("GerbilManagerWebAPI.Models.Contact", "OriginContact") + .WithMany() + .HasForeignKey("OriginContactId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("GerbilManagerWebAPI.Models.Contact", "ReceiverContact") + .WithMany() + .HasForeignKey("ReceiverContactId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ColorVariety"); + + b.Navigation("Enclosure"); + + b.Navigation("Litter"); + + b.Navigation("OriginContact"); + + b.Navigation("ReceiverContact"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.GerbilPhoto", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", null) + .WithMany() + .HasForeignKey("GerbilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.HealthRecord", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", null) + .WithMany() + .HasForeignKey("GerbilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father") + .WithMany() + .HasForeignKey("FatherId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother") + .WithMany() + .HasForeignKey("MotherId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Father"); + + b.Navigation("Mother"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.WeightRecord", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", null) + .WithMany() + .HasForeignKey("GerbilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Enclosure", b => + { + b.Navigation("Gerbils"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/GerbilManagerWebAPI/Migrations/20260605225413_InitialCreate.cs b/GerbilManagerWebAPI/Migrations/20260605225413_InitialCreate.cs new file mode 100644 index 0000000..80765c4 --- /dev/null +++ b/GerbilManagerWebAPI/Migrations/20260605225413_InitialCreate.cs @@ -0,0 +1,326 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace GerbilManagerWebAPI.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "ColorVarieties", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + CanonicalGenotype = table.Column(type: "text", nullable: true), + SortOrder = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ColorVarieties", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Contacts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + ContactInfo = table.Column(type: "text", nullable: true), + Notes = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Contacts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Enclosures", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Name = table.Column(type: "text", nullable: false), + Notes = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Enclosures", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "GerbilPhotos", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + GerbilId = table.Column(type: "uuid", nullable: false), + FileName = table.Column(type: "text", nullable: false), + Caption = table.Column(type: "text", nullable: true), + SortOrder = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_GerbilPhotos", 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), + Status = table.Column(type: "text", nullable: false), + LitterId = table.Column(type: "uuid", nullable: true), + OriginContactId = table.Column(type: "uuid", nullable: true), + ReceiverContactId = table.Column(type: "uuid", nullable: true), + EnclosureId = table.Column(type: "uuid", nullable: true), + ColorVarietyId = table.Column(type: "uuid", nullable: true), + DateOfBirth = table.Column(type: "date", nullable: true), + DateOfDeath = table.Column(type: "date", nullable: true), + CauseOfDeath = table.Column(type: "text", nullable: true), + GoHomeDate = table.Column(type: "date", nullable: true), + Genotype = table.Column(type: "text", nullable: true), + Notes = table.Column(type: "text", nullable: true), + ImportSource = table.Column(type: "text", nullable: true), + ExternalRef = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Gerbils", x => x.Id); + table.ForeignKey( + name: "FK_Gerbils_ColorVarieties_ColorVarietyId", + column: x => x.ColorVarietyId, + principalTable: "ColorVarieties", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + table.ForeignKey( + name: "FK_Gerbils_Contacts_OriginContactId", + column: x => x.OriginContactId, + principalTable: "Contacts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Gerbils_Contacts_ReceiverContactId", + column: x => x.ReceiverContactId, + principalTable: "Contacts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Gerbils_Enclosures_EnclosureId", + column: x => x.EnclosureId, + principalTable: "Enclosures", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + }); + + migrationBuilder.CreateTable( + name: "HealthRecords", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + GerbilId = table.Column(type: "uuid", nullable: false), + Date = table.Column(type: "date", nullable: false), + Type = table.Column(type: "text", nullable: false), + Description = table.Column(type: "text", nullable: false), + Veterinarian = table.Column(type: "text", nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_HealthRecords", x => x.Id); + table.ForeignKey( + name: "FK_HealthRecords_Gerbils_GerbilId", + column: x => x.GerbilId, + principalTable: "Gerbils", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + 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: "date", nullable: false), + TotalBorn = table.Column(type: "integer", nullable: true), + FatherId = table.Column(type: "uuid", nullable: true), + MotherId = table.Column(type: "uuid", nullable: true), + ExpectedGoHomeDate = table.Column(type: "date", nullable: true), + Notes = table.Column(type: "text", 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", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Litters_Gerbils_MotherId", + column: x => x.MotherId, + principalTable: "Gerbils", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "WeightRecords", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + GerbilId = table.Column(type: "uuid", nullable: false), + Date = table.Column(type: "date", nullable: false), + WeightGrams = table.Column(type: "integer", nullable: false), + Notes = table.Column(type: "text", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_WeightRecords", x => x.Id); + table.ForeignKey( + name: "FK_WeightRecords_Gerbils_GerbilId", + column: x => x.GerbilId, + principalTable: "Gerbils", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.InsertData( + table: "ColorVarieties", + columns: new[] { "Id", "CanonicalGenotype", "Name", "SortOrder" }, + values: new object[,] + { + { new Guid("00000000-0000-0000-0000-000000000001"), "AA chch DD EE GG pp spsp rere", "Pink Eyed White (PEW)", 0 }, + { new Guid("00000000-0000-0000-0000-000000000002"), "aa chch DD EE GG PP spsp rere", "Hermelin", 1 }, + { new Guid("00000000-0000-0000-0000-000000000003"), "AA chch DD EE GG PP spsp rere", "Himalaya", 2 }, + { new Guid("00000000-0000-0000-0000-000000000004"), "aa cchmcchm DD EE gg PP spsp rere", "Zobel", 3 }, + { new Guid("00000000-0000-0000-0000-000000000005"), "AA CC DD efef GG PP spsp rere", "Schwarzschimmel", 4 }, + { new Guid("00000000-0000-0000-0000-000000000006"), "AA CC DD efef GG pp spsp rere", "Rotaugenschimmel", 5 }, + { new Guid("00000000-0000-0000-0000-000000000007"), "AA CC DD EE GG PP spsp rere", "Agouti", 6 }, + { new Guid("00000000-0000-0000-0000-000000000008"), "aa CC DD EE GG PP spsp rere", "Schwarz", 7 }, + { new Guid("00000000-0000-0000-0000-000000000009"), "AA CC DD EE gg PP spsp rere", "Silberagouti", 8 }, + { new Guid("00000000-0000-0000-0000-000000000010"), "aa CC DD EE gg PP spsp rere", "Anthrazit", 9 }, + { new Guid("00000000-0000-0000-0000-000000000011"), "AA CC DD ee GG PP spsp rere", "Algierfuchs", 10 }, + { new Guid("00000000-0000-0000-0000-000000000012"), "aa CC dd EE GG PP spsp rere", "Blau", 11 }, + { new Guid("00000000-0000-0000-0000-000000000013"), "AA CC DD EE GG pp spsp rere", "Gold", 12 }, + { new Guid("00000000-0000-0000-0000-000000000014"), "aa CC DD EE GG pp spsp rere", "Platin", 13 }, + { new Guid("00000000-0000-0000-0000-000000000015"), "AA CC DD ee GG pp spsp rere", "Goldfuchs", 14 }, + { new Guid("00000000-0000-0000-0000-000000000016"), "aa CC DD ee GG pp spsp rere", "Rotfuchs", 15 }, + { new Guid("00000000-0000-0000-0000-000000000017"), "AA CC dd EE GG pp spsp rere", "dd Gold", 16 }, + { new Guid("00000000-0000-0000-0000-000000000018"), "aa CC dd EE GG pp spsp rere", "dd Platin", 17 } + }); + + migrationBuilder.CreateIndex( + name: "IX_GerbilPhotos_GerbilId", + table: "GerbilPhotos", + column: "GerbilId"); + + migrationBuilder.CreateIndex( + name: "IX_Gerbils_ColorVarietyId", + table: "Gerbils", + column: "ColorVarietyId"); + + migrationBuilder.CreateIndex( + name: "IX_Gerbils_EnclosureId", + table: "Gerbils", + column: "EnclosureId"); + + migrationBuilder.CreateIndex( + name: "IX_Gerbils_LitterId", + table: "Gerbils", + column: "LitterId"); + + migrationBuilder.CreateIndex( + name: "IX_Gerbils_OriginContactId", + table: "Gerbils", + column: "OriginContactId"); + + migrationBuilder.CreateIndex( + name: "IX_Gerbils_ReceiverContactId", + table: "Gerbils", + column: "ReceiverContactId"); + + migrationBuilder.CreateIndex( + name: "IX_HealthRecords_GerbilId", + table: "HealthRecords", + column: "GerbilId"); + + migrationBuilder.CreateIndex( + name: "IX_Litters_FatherId", + table: "Litters", + column: "FatherId"); + + migrationBuilder.CreateIndex( + name: "IX_Litters_MotherId", + table: "Litters", + column: "MotherId"); + + migrationBuilder.CreateIndex( + name: "IX_WeightRecords_GerbilId", + table: "WeightRecords", + column: "GerbilId"); + + migrationBuilder.AddForeignKey( + name: "FK_GerbilPhotos_Gerbils_GerbilId", + table: "GerbilPhotos", + column: "GerbilId", + principalTable: "Gerbils", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Gerbils_Litters_LitterId", + table: "Gerbils", + column: "LitterId", + principalTable: "Litters", + principalColumn: "Id", + onDelete: ReferentialAction.SetNull); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Litters_Gerbils_FatherId", + table: "Litters"); + + migrationBuilder.DropForeignKey( + name: "FK_Litters_Gerbils_MotherId", + table: "Litters"); + + migrationBuilder.DropTable( + name: "GerbilPhotos"); + + migrationBuilder.DropTable( + name: "HealthRecords"); + + migrationBuilder.DropTable( + name: "WeightRecords"); + + migrationBuilder.DropTable( + name: "Gerbils"); + + migrationBuilder.DropTable( + name: "ColorVarieties"); + + migrationBuilder.DropTable( + name: "Contacts"); + + migrationBuilder.DropTable( + name: "Enclosures"); + + migrationBuilder.DropTable( + name: "Litters"); + } + } +} diff --git a/GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs b/GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs index 95e0d3c..74cf343 100644 --- a/GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs +++ b/GerbilManagerWebAPI/Migrations/ApplicationContextModelSnapshot.cs @@ -21,7 +21,177 @@ namespace GerbilManagerWebAPI.Migrations NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("GerbilManagerWebAPI.Models.Breeder", b => + modelBuilder.Entity("GerbilManagerWebAPI.Models.ColorVariety", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CanonicalGenotype") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("ColorVarieties"); + + b.HasData( + new + { + Id = new Guid("00000000-0000-0000-0000-000000000001"), + CanonicalGenotype = "AA chch DD EE GG pp spsp rere", + Name = "Pink Eyed White (PEW)", + SortOrder = 0 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000002"), + CanonicalGenotype = "aa chch DD EE GG PP spsp rere", + Name = "Hermelin", + SortOrder = 1 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000003"), + CanonicalGenotype = "AA chch DD EE GG PP spsp rere", + Name = "Himalaya", + SortOrder = 2 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000004"), + CanonicalGenotype = "aa cchmcchm DD EE gg PP spsp rere", + Name = "Zobel", + SortOrder = 3 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000005"), + CanonicalGenotype = "AA CC DD efef GG PP spsp rere", + Name = "Schwarzschimmel", + SortOrder = 4 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000006"), + CanonicalGenotype = "AA CC DD efef GG pp spsp rere", + Name = "Rotaugenschimmel", + SortOrder = 5 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000007"), + CanonicalGenotype = "AA CC DD EE GG PP spsp rere", + Name = "Agouti", + SortOrder = 6 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000008"), + CanonicalGenotype = "aa CC DD EE GG PP spsp rere", + Name = "Schwarz", + SortOrder = 7 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000009"), + CanonicalGenotype = "AA CC DD EE gg PP spsp rere", + Name = "Silberagouti", + SortOrder = 8 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000010"), + CanonicalGenotype = "aa CC DD EE gg PP spsp rere", + Name = "Anthrazit", + SortOrder = 9 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000011"), + CanonicalGenotype = "AA CC DD ee GG PP spsp rere", + Name = "Algierfuchs", + SortOrder = 10 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000012"), + CanonicalGenotype = "aa CC dd EE GG PP spsp rere", + Name = "Blau", + SortOrder = 11 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000013"), + CanonicalGenotype = "AA CC DD EE GG pp spsp rere", + Name = "Gold", + SortOrder = 12 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000014"), + CanonicalGenotype = "aa CC DD EE GG pp spsp rere", + Name = "Platin", + SortOrder = 13 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000015"), + CanonicalGenotype = "AA CC DD ee GG pp spsp rere", + Name = "Goldfuchs", + SortOrder = 14 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000016"), + CanonicalGenotype = "aa CC DD ee GG pp spsp rere", + Name = "Rotfuchs", + SortOrder = 15 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000017"), + CanonicalGenotype = "AA CC dd EE GG pp spsp rere", + Name = "dd Gold", + SortOrder = 16 + }, + new + { + Id = new Guid("00000000-0000-0000-0000-000000000018"), + CanonicalGenotype = "aa CC dd EE GG pp spsp rere", + Name = "dd Platin", + SortOrder = 17 + }); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Contact", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ContactInfo") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("Notes") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Contacts"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Enclosure", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -31,9 +201,12 @@ namespace GerbilManagerWebAPI.Migrations .IsRequired() .HasColumnType("text"); + b.Property("Notes") + .HasColumnType("text"); + b.HasKey("Id"); - b.ToTable("Breeders", (string)null); + b.ToTable("Enclosures"); }); modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => @@ -42,13 +215,37 @@ namespace GerbilManagerWebAPI.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("BreederId") + b.Property("CauseOfDeath") + .HasColumnType("text"); + + b.Property("ColorVarietyId") .HasColumnType("uuid"); + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("DateOfDeath") + .HasColumnType("date"); + + b.Property("EnclosureId") + .HasColumnType("uuid"); + + b.Property("ExternalRef") + .HasColumnType("text"); + b.Property("Gender") .IsRequired() .HasColumnType("text"); + b.Property("Genotype") + .HasColumnType("text"); + + b.Property("GoHomeDate") + .HasColumnType("date"); + + b.Property("ImportSource") + .HasColumnType("text"); + b.Property("LitterId") .HasColumnType("uuid"); @@ -56,13 +253,94 @@ namespace GerbilManagerWebAPI.Migrations .IsRequired() .HasColumnType("text"); + b.Property("Notes") + .HasColumnType("text"); + + b.Property("OriginContactId") + .HasColumnType("uuid"); + + b.Property("ReceiverContactId") + .HasColumnType("uuid"); + + b.Property("Status") + .IsRequired() + .HasColumnType("text"); + b.HasKey("Id"); - b.HasIndex("BreederId"); + b.HasIndex("ColorVarietyId"); + + b.HasIndex("EnclosureId"); b.HasIndex("LitterId"); - b.ToTable("Gerbils", (string)null); + b.HasIndex("OriginContactId"); + + b.HasIndex("ReceiverContactId"); + + b.ToTable("Gerbils"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.GerbilPhoto", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Caption") + .HasColumnType("text"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("text"); + + b.Property("GerbilId") + .HasColumnType("uuid"); + + b.Property("SortOrder") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GerbilId"); + + b.ToTable("GerbilPhotos"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.HealthRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("GerbilId") + .HasColumnType("uuid"); + + b.Property("Type") + .IsRequired() + .HasColumnType("text"); + + b.Property("Veterinarian") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("GerbilId"); + + b.ToTable("HealthRecords"); }); modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => @@ -71,8 +349,11 @@ namespace GerbilManagerWebAPI.Migrations .ValueGeneratedOnAdd() .HasColumnType("uuid"); - b.Property("Date") - .HasColumnType("timestamp with time zone"); + b.Property("Date") + .HasColumnType("date"); + + b.Property("ExpectedGoHomeDate") + .HasColumnType("date"); b.Property("FatherId") .HasColumnType("uuid"); @@ -84,7 +365,10 @@ namespace GerbilManagerWebAPI.Migrations .IsRequired() .HasColumnType("text"); - b.Property("Strength") + b.Property("Notes") + .HasColumnType("text"); + + b.Property("TotalBorn") .HasColumnType("integer"); b.HasKey("Id"); @@ -93,38 +377,120 @@ namespace GerbilManagerWebAPI.Migrations b.HasIndex("MotherId"); - b.ToTable("Litters", (string)null); + b.ToTable("Litters"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.WeightRecord", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("GerbilId") + .HasColumnType("uuid"); + + b.Property("Notes") + .HasColumnType("text"); + + b.Property("WeightGrams") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("GerbilId"); + + b.ToTable("WeightRecords"); }); modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => { - b.HasOne("GerbilManagerWebAPI.Models.Breeder", "Breeder") + b.HasOne("GerbilManagerWebAPI.Models.ColorVariety", "ColorVariety") .WithMany() - .HasForeignKey("BreederId"); + .HasForeignKey("ColorVarietyId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("GerbilManagerWebAPI.Models.Enclosure", "Enclosure") + .WithMany("Gerbils") + .HasForeignKey("EnclosureId") + .OnDelete(DeleteBehavior.SetNull); b.HasOne("GerbilManagerWebAPI.Models.Litter", "Litter") .WithMany() - .HasForeignKey("LitterId"); + .HasForeignKey("LitterId") + .OnDelete(DeleteBehavior.SetNull); - b.Navigation("Breeder"); + b.HasOne("GerbilManagerWebAPI.Models.Contact", "OriginContact") + .WithMany() + .HasForeignKey("OriginContactId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("GerbilManagerWebAPI.Models.Contact", "ReceiverContact") + .WithMany() + .HasForeignKey("ReceiverContactId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ColorVariety"); + + b.Navigation("Enclosure"); b.Navigation("Litter"); + + b.Navigation("OriginContact"); + + b.Navigation("ReceiverContact"); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.GerbilPhoto", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", null) + .WithMany() + .HasForeignKey("GerbilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.HealthRecord", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", null) + .WithMany() + .HasForeignKey("GerbilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => { b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father") .WithMany() - .HasForeignKey("FatherId"); + .HasForeignKey("FatherId") + .OnDelete(DeleteBehavior.Restrict); b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother") .WithMany() - .HasForeignKey("MotherId"); + .HasForeignKey("MotherId") + .OnDelete(DeleteBehavior.Restrict); b.Navigation("Father"); b.Navigation("Mother"); }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.WeightRecord", b => + { + b.HasOne("GerbilManagerWebAPI.Models.Gerbil", null) + .WithMany() + .HasForeignKey("GerbilId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("GerbilManagerWebAPI.Models.Enclosure", b => + { + b.Navigation("Gerbils"); + }); #pragma warning restore 612, 618 } }