using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace ConfectioneryDatabaseImplement.Migrations { /// public partial class migration2 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "ClientId", table: "Orders", type: "integer", nullable: true); migrationBuilder.CreateTable( name: "Clients", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ClientFIO = table.Column(type: "text", nullable: false), Email = table.Column(type: "text", nullable: false), Password = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clients", x => x.Id); }); migrationBuilder.CreateIndex( name: "IX_Orders_ClientId", table: "Orders", column: "ClientId"); migrationBuilder.CreateIndex( name: "IX_Orders_PastryId", table: "Orders", column: "PastryId"); migrationBuilder.AddForeignKey( name: "FK_Orders_Clients_ClientId", table: "Orders", column: "ClientId", principalTable: "Clients", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_Orders_Pastries_PastryId", table: "Orders", column: "PastryId", principalTable: "Pastries", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Orders_Clients_ClientId", table: "Orders"); migrationBuilder.DropForeignKey( name: "FK_Orders_Pastries_PastryId", table: "Orders"); migrationBuilder.DropTable( name: "Clients"); migrationBuilder.DropIndex( name: "IX_Orders_ClientId", table: "Orders"); migrationBuilder.DropIndex( name: "IX_Orders_PastryId", table: "Orders"); migrationBuilder.DropColumn( name: "ClientId", table: "Orders"); } } }