using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace SushiBarDatabaseImplement.Migrations { /// public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Buyers", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), BuyerName = table.Column(type: "text", nullable: false), BuyerBirthDate = table.Column(type: "timestamp without time zone", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Buyers", x => x.Id); }); migrationBuilder.CreateTable( name: "Cooks", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), CookName = table.Column(type: "text", nullable: false), CookSurname = table.Column(type: "text", nullable: false), Experience = table.Column(type: "integer", nullable: false), PhoneNumber = table.Column(type: "text", nullable: false), Passport = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Cooks", x => x.Id); }); migrationBuilder.CreateTable( name: "Menus", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), FoodName = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), Price = table.Column(type: "double precision", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Menus", x => x.Id); }); migrationBuilder.CreateTable( name: "Places", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), PlaceNumber = table.Column(type: "integer", nullable: false), CountPlaces = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Places", x => x.Id); }); migrationBuilder.CreateTable( name: "Tasks", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), TaskDate = table.Column(type: "timestamp without time zone", nullable: false), Status = table.Column(type: "integer", nullable: false), FullPrice = table.Column(type: "double precision", nullable: false), PlaceId = table.Column(type: "integer", nullable: false), CookId = table.Column(type: "integer", nullable: false), BuyerId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Tasks", x => x.Id); }); migrationBuilder.CreateTable( name: "TaskMenus", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), TaskId = table.Column(type: "integer", nullable: false), MenuId = table.Column(type: "integer", nullable: false), Count = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskMenus", x => x.Id); table.ForeignKey( name: "FK_TaskMenus_Menus_MenuId", column: x => x.MenuId, principalTable: "Menus", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TaskMenus_Tasks_TaskId", column: x => x.TaskId, principalTable: "Tasks", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_TaskMenus_MenuId", table: "TaskMenus", column: "MenuId"); migrationBuilder.CreateIndex( name: "IX_TaskMenus_TaskId", table: "TaskMenus", column: "TaskId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Buyers"); migrationBuilder.DropTable( name: "Cooks"); migrationBuilder.DropTable( name: "Places"); migrationBuilder.DropTable( name: "TaskMenus"); migrationBuilder.DropTable( name: "Menus"); migrationBuilder.DropTable( name: "Tasks"); } } }