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: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Breeders", 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), LitterId = table.Column(type: "uuid", nullable: true), BreederId = table.Column(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(type: "uuid", nullable: false), Name = table.Column(type: "text", nullable: false), Date = table.Column(type: "timestamp with time zone", nullable: false), Strength = table.Column(type: "integer", nullable: true), FatherId = table.Column(type: "uuid", nullable: true), MotherId = table.Column(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"); } /// 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"); } } }