using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace GerbilManagerWebAPI.Migrations { /// public partial class SaleContractsAndBreederSettings : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "BreederSettings", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ZuchtName = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), Address = table.Column(type: "text", nullable: false), Phone = table.Column(type: "text", nullable: false), Email = table.Column(type: "text", nullable: false), Homepage = table.Column(type: "text", nullable: false), City = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_BreederSettings", x => x.Id); }); migrationBuilder.CreateTable( name: "SaleContracts", columns: table => new { Id = table.Column(type: "uuid", nullable: false), ContactId = table.Column(type: "uuid", nullable: false), Price = table.Column(type: "numeric(10,2)", precision: 10, scale: 2, nullable: false), HandoverDate = table.Column(type: "date", nullable: false), ContractDate = table.Column(type: "date", nullable: false), FileName = table.Column(type: "text", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SaleContracts", x => x.Id); table.ForeignKey( name: "FK_SaleContracts_Contacts_ContactId", column: x => x.ContactId, principalTable: "Contacts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "SaleContractAnimal", columns: table => new { SaleContractId = table.Column(type: "uuid", nullable: false), GerbilId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_SaleContractAnimal", x => new { x.SaleContractId, x.GerbilId }); table.ForeignKey( name: "FK_SaleContractAnimal_Gerbils_GerbilId", column: x => x.GerbilId, principalTable: "Gerbils", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_SaleContractAnimal_SaleContracts_SaleContractId", column: x => x.SaleContractId, principalTable: "SaleContracts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( table: "BreederSettings", columns: new[] { "Id", "Address", "City", "Email", "Homepage", "Name", "Phone", "ZuchtName" }, values: new object[] { new Guid("11111111-1111-1111-1111-000000000001"), "", "", "", "", "", "", "" }); migrationBuilder.CreateIndex( name: "IX_SaleContractAnimal_GerbilId", table: "SaleContractAnimal", column: "GerbilId"); migrationBuilder.CreateIndex( name: "IX_SaleContracts_ContactId", table: "SaleContracts", column: "ContactId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "BreederSettings"); migrationBuilder.DropTable( name: "SaleContractAnimal"); migrationBuilder.DropTable( name: "SaleContracts"); } } }