Files
GerbilManager/GerbilManagerWebAPI/Migrations/20260605213640_InitialCreate.cs
Gulum cc589b13d0 ARCH-2: fresh Npgsql initial migration
uuid keys, text columns, Gender persisted as text via EnumToStringConverter,
Litter.Date as timestamptz. Replaces deleted SqlServer initialCreate (no prod data).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 23:37:21 +02:00

122 lines
4.5 KiB
C#

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