DATA-2: fresh Npgsql InitialCreate migration + ColorVariety seed (18)

8 tables (Gerbils, Litters, Contacts, Enclosures, ColorVarieties, GerbilPhotos,
HealthRecords, WeightRecords); enums as text columns; ColorVariety HasData seed
of the 18 GEN-1 base varieties. Replaces the prior pre-DATA-2 InitialCreate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-06 00:54:56 +02:00
parent 180d53b203
commit 263ba32e3c
5 changed files with 1207 additions and 270 deletions

View File

@@ -1,134 +0,0 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Breeders", (string)null);
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<Guid?>("BreederId")
.HasColumnType("uuid");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("text");
b.Property<Guid?>("LitterId")
.HasColumnType("uuid");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("FatherId")
.HasColumnType("uuid");
b.Property<Guid?>("MotherId")
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int?>("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
}
}
}

View File

@@ -1,121 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GerbilManagerWebAPI.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Breeders",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Breeders", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Gerbils",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Gender = table.Column<string>(type: "text", nullable: false),
LitterId = table.Column<Guid>(type: "uuid", nullable: true),
BreederId = table.Column<Guid>(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<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Strength = table.Column<int>(type: "integer", nullable: true),
FatherId = table.Column<Guid>(type: "uuid", nullable: true),
MotherId = table.Column<Guid>(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");
}
/// <inheritdoc />
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");
}
}
}

View File

@@ -0,0 +1,500 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CanonicalGenotype")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ContactInfo")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Notes")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Contacts");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Enclosure", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Notes")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Enclosures");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CauseOfDeath")
.HasColumnType("text");
b.Property<Guid?>("ColorVarietyId")
.HasColumnType("uuid");
b.Property<DateOnly?>("DateOfBirth")
.HasColumnType("date");
b.Property<DateOnly?>("DateOfDeath")
.HasColumnType("date");
b.Property<Guid?>("EnclosureId")
.HasColumnType("uuid");
b.Property<string>("ExternalRef")
.HasColumnType("text");
b.Property<string>("Gender")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Genotype")
.HasColumnType("text");
b.Property<DateOnly?>("GoHomeDate")
.HasColumnType("date");
b.Property<string>("ImportSource")
.HasColumnType("text");
b.Property<Guid?>("LitterId")
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<Guid?>("OriginContactId")
.HasColumnType("uuid");
b.Property<Guid?>("ReceiverContactId")
.HasColumnType("uuid");
b.Property<string>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Caption")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FileName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("GerbilId")
.HasColumnType("uuid");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GerbilId");
b.ToTable("GerbilPhotos");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.HealthRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("GerbilId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Veterinarian")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("GerbilId");
b.ToTable("HealthRecords");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<DateOnly?>("ExpectedGoHomeDate")
.HasColumnType("date");
b.Property<Guid?>("FatherId")
.HasColumnType("uuid");
b.Property<Guid?>("MotherId")
.HasColumnType("uuid");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<int?>("TotalBorn")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("FatherId");
b.HasIndex("MotherId");
b.ToTable("Litters");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.WeightRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<Guid>("GerbilId")
.HasColumnType("uuid");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<int>("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
}
}
}

View File

@@ -0,0 +1,326 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace GerbilManagerWebAPI.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ColorVarieties",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
CanonicalGenotype = table.Column<string>(type: "text", nullable: true),
SortOrder = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ColorVarieties", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Contacts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
ContactInfo = table.Column<string>(type: "text", nullable: true),
Notes = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Contacts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Enclosures",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Notes = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Enclosures", x => x.Id);
});
migrationBuilder.CreateTable(
name: "GerbilPhotos",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
GerbilId = table.Column<Guid>(type: "uuid", nullable: false),
FileName = table.Column<string>(type: "text", nullable: false),
Caption = table.Column<string>(type: "text", nullable: true),
SortOrder = table.Column<int>(type: "integer", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(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<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Gender = table.Column<string>(type: "text", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
LitterId = table.Column<Guid>(type: "uuid", nullable: true),
OriginContactId = table.Column<Guid>(type: "uuid", nullable: true),
ReceiverContactId = table.Column<Guid>(type: "uuid", nullable: true),
EnclosureId = table.Column<Guid>(type: "uuid", nullable: true),
ColorVarietyId = table.Column<Guid>(type: "uuid", nullable: true),
DateOfBirth = table.Column<DateOnly>(type: "date", nullable: true),
DateOfDeath = table.Column<DateOnly>(type: "date", nullable: true),
CauseOfDeath = table.Column<string>(type: "text", nullable: true),
GoHomeDate = table.Column<DateOnly>(type: "date", nullable: true),
Genotype = table.Column<string>(type: "text", nullable: true),
Notes = table.Column<string>(type: "text", nullable: true),
ImportSource = table.Column<string>(type: "text", nullable: true),
ExternalRef = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
GerbilId = table.Column<Guid>(type: "uuid", nullable: false),
Date = table.Column<DateOnly>(type: "date", nullable: false),
Type = table.Column<string>(type: "text", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Veterinarian = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(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<Guid>(type: "uuid", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
Date = table.Column<DateOnly>(type: "date", nullable: false),
TotalBorn = table.Column<int>(type: "integer", nullable: true),
FatherId = table.Column<Guid>(type: "uuid", nullable: true),
MotherId = table.Column<Guid>(type: "uuid", nullable: true),
ExpectedGoHomeDate = table.Column<DateOnly>(type: "date", nullable: true),
Notes = table.Column<string>(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<Guid>(type: "uuid", nullable: false),
GerbilId = table.Column<Guid>(type: "uuid", nullable: false),
Date = table.Column<DateOnly>(type: "date", nullable: false),
WeightGrams = table.Column<int>(type: "integer", nullable: false),
Notes = table.Column<string>(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);
}
/// <inheritdoc />
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");
}
}
}

View File

@@ -21,7 +21,177 @@ namespace GerbilManagerWebAPI.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("GerbilManagerWebAPI.Models.Breeder", b => modelBuilder.Entity("GerbilManagerWebAPI.Models.ColorVariety", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("CanonicalGenotype")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<int>("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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("ContactInfo")
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Notes")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Contacts");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.Enclosure", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
@@ -31,9 +201,12 @@ namespace GerbilManagerWebAPI.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Notes")
.HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Breeders", (string)null); b.ToTable("Enclosures");
}); });
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
@@ -42,13 +215,37 @@ namespace GerbilManagerWebAPI.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<Guid?>("BreederId") b.Property<string>("CauseOfDeath")
.HasColumnType("text");
b.Property<Guid?>("ColorVarietyId")
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateOnly?>("DateOfBirth")
.HasColumnType("date");
b.Property<DateOnly?>("DateOfDeath")
.HasColumnType("date");
b.Property<Guid?>("EnclosureId")
.HasColumnType("uuid");
b.Property<string>("ExternalRef")
.HasColumnType("text");
b.Property<string>("Gender") b.Property<string>("Gender")
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Genotype")
.HasColumnType("text");
b.Property<DateOnly?>("GoHomeDate")
.HasColumnType("date");
b.Property<string>("ImportSource")
.HasColumnType("text");
b.Property<Guid?>("LitterId") b.Property<Guid?>("LitterId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@@ -56,13 +253,94 @@ namespace GerbilManagerWebAPI.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<Guid?>("OriginContactId")
.HasColumnType("uuid");
b.Property<Guid?>("ReceiverContactId")
.HasColumnType("uuid");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("BreederId"); b.HasIndex("ColorVarietyId");
b.HasIndex("EnclosureId");
b.HasIndex("LitterId"); 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<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Caption")
.HasColumnType("text");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("FileName")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("GerbilId")
.HasColumnType("uuid");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GerbilId");
b.ToTable("GerbilPhotos");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.HealthRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<Guid>("GerbilId")
.HasColumnType("uuid");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Veterinarian")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("GerbilId");
b.ToTable("HealthRecords");
}); });
modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b => modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b =>
@@ -71,8 +349,11 @@ namespace GerbilManagerWebAPI.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("uuid"); .HasColumnType("uuid");
b.Property<DateTime>("Date") b.Property<DateOnly>("Date")
.HasColumnType("timestamp with time zone"); .HasColumnType("date");
b.Property<DateOnly?>("ExpectedGoHomeDate")
.HasColumnType("date");
b.Property<Guid?>("FatherId") b.Property<Guid?>("FatherId")
.HasColumnType("uuid"); .HasColumnType("uuid");
@@ -84,7 +365,10 @@ namespace GerbilManagerWebAPI.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<int?>("Strength") b.Property<string>("Notes")
.HasColumnType("text");
b.Property<int?>("TotalBorn")
.HasColumnType("integer"); .HasColumnType("integer");
b.HasKey("Id"); b.HasKey("Id");
@@ -93,38 +377,120 @@ namespace GerbilManagerWebAPI.Migrations
b.HasIndex("MotherId"); b.HasIndex("MotherId");
b.ToTable("Litters", (string)null); b.ToTable("Litters");
});
modelBuilder.Entity("GerbilManagerWebAPI.Models.WeightRecord", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<Guid>("GerbilId")
.HasColumnType("uuid");
b.Property<string>("Notes")
.HasColumnType("text");
b.Property<int>("WeightGrams")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("GerbilId");
b.ToTable("WeightRecords");
}); });
modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b => modelBuilder.Entity("GerbilManagerWebAPI.Models.Gerbil", b =>
{ {
b.HasOne("GerbilManagerWebAPI.Models.Breeder", "Breeder") b.HasOne("GerbilManagerWebAPI.Models.ColorVariety", "ColorVariety")
.WithMany() .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") b.HasOne("GerbilManagerWebAPI.Models.Litter", "Litter")
.WithMany() .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("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 => modelBuilder.Entity("GerbilManagerWebAPI.Models.Litter", b =>
{ {
b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father") b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Father")
.WithMany() .WithMany()
.HasForeignKey("FatherId"); .HasForeignKey("FatherId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother") b.HasOne("GerbilManagerWebAPI.Models.Gerbil", "Mother")
.WithMany() .WithMany()
.HasForeignKey("MotherId"); .HasForeignKey("MotherId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Father"); b.Navigation("Father");
b.Navigation("Mother"); 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 #pragma warning restore 612, 618
} }
} }