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>
327 lines
16 KiB
C#
327 lines
16 KiB
C#
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");
|
|
}
|
|
}
|
|
}
|