This commit is contained in:
2023-10-30 21:58:56 +01:00
parent 5792d2fcf4
commit 08983ba30d
7 changed files with 38 additions and 29 deletions

View File

@@ -0,0 +1,121 @@
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: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Breeders", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Gerbils",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Gender = table.Column<string>(type: "nvarchar(max)", nullable: false),
LitterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
BreederId = table.Column<Guid>(type: "uniqueidentifier", 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: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
Strength = table.Column<int>(type: "int", nullable: true),
FatherId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
MotherId = table.Column<Guid>(type: "uniqueidentifier", 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");
}
}
}