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"); } } }