using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace GerbilManagerWebAPI.Migrations
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Breeders",
columns: table => new
{
Id = table.Column(type: "uniqueidentifier", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Breeders", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Gerbils",
columns: table => new
{
Id = table.Column(type: "uniqueidentifier", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: true),
Gender = table.Column(type: "nvarchar(max)", nullable: false),
LitterId = table.Column(type: "uniqueidentifier", nullable: true),
BreederId = table.Column(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(type: "uniqueidentifier", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: true),
Date = table.Column(type: "datetime2", nullable: false),
Strength = table.Column(type: "int", nullable: false),
FatherId = table.Column(type: "uniqueidentifier", nullable: true),
MotherId = table.Column(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");
}
///
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");
}
}
}