using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace HotelDataBaseImplement.Migrations { /// public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Administrators", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), AdministratorFIO = table.Column(type: "nvarchar(max)", nullable: false), AdministratorPhone = table.Column(type: "nvarchar(max)", nullable: false), AdministratorLogin = table.Column(type: "nvarchar(max)", nullable: false), AdministratorPassword = table.Column(type: "nvarchar(max)", nullable: false), AdministratorEmail = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Administrators", x => x.Id); }); migrationBuilder.CreateTable( name: "Organisers", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrganiserLogin = table.Column(type: "nvarchar(max)", nullable: false), OrganiserPassword = table.Column(type: "nvarchar(max)", nullable: false), OrganiserEmail = table.Column(type: "nvarchar(max)", nullable: false), OrganiserNumber = table.Column(type: "nvarchar(max)", nullable: false), OrganiserFIO = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Organisers", x => x.Id); }); migrationBuilder.CreateTable( name: "Dinners", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DinnerName = table.Column(type: "nvarchar(max)", nullable: false), DinnerСalorieСontent = table.Column(type: "int", nullable: false), DinnerPrice = table.Column(type: "float", nullable: false), AdministratorId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Dinners", x => x.Id); table.ForeignKey( name: "FK_Dinners_Administrators_AdministratorId", column: x => x.AdministratorId, principalTable: "Administrators", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Conferences", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ConferenceName = table.Column(type: "nvarchar(max)", nullable: false), Subject = table.Column(type: "nvarchar(max)", nullable: false), StartDate = table.Column(type: "datetime2", nullable: false), OrganiserId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Conferences", x => x.Id); table.ForeignKey( name: "FK_Conferences_Organisers_OrganiserId", column: x => x.OrganiserId, principalTable: "Organisers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MealPlans", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), MealPlanName = table.Column(type: "nvarchar(max)", nullable: false), MealPlanPrice = table.Column(type: "float", nullable: false), OrganiserId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MealPlans", x => x.Id); table.ForeignKey( name: "FK_MealPlans_Organisers_OrganiserId", column: x => x.OrganiserId, principalTable: "Organisers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Participants", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ParticipantFIO = table.Column(type: "nvarchar(max)", nullable: false), Number = table.Column(type: "nvarchar(max)", nullable: false), OrganiserId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Participants", x => x.Id); table.ForeignKey( name: "FK_Participants_Organisers_OrganiserId", column: x => x.OrganiserId, principalTable: "Organisers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ConferenceBookings", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), DateСonference = table.Column(type: "datetime2", nullable: true), AdministratorId = table.Column(type: "int", nullable: false), ConferenceId = table.Column(type: "int", nullable: true), PlaceСonference = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ConferenceBookings", x => x.Id); table.ForeignKey( name: "FK_ConferenceBookings_Administrators_AdministratorId", column: x => x.AdministratorId, principalTable: "Administrators", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ConferenceBookings_Conferences_ConferenceId", column: x => x.ConferenceId, principalTable: "Conferences", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "Rooms", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), RoomNumber = table.Column(type: "int", nullable: false), RoomPrice = table.Column(type: "float", nullable: false), DateCreate = table.Column(type: "datetime2", nullable: false), AdministratorId = table.Column(type: "int", nullable: false), MealPlanId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Rooms", x => x.Id); table.ForeignKey( name: "FK_Rooms_Administrators_AdministratorId", column: x => x.AdministratorId, principalTable: "Administrators", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Rooms_MealPlans_MealPlanId", column: x => x.MealPlanId, principalTable: "MealPlans", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ConferenceParticipants", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ParticipantId = table.Column(type: "int", nullable: false), ConferenceId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ConferenceParticipants", x => x.Id); table.ForeignKey( name: "FK_ConferenceParticipants_Conferences_ConferenceId", column: x => x.ConferenceId, principalTable: "Conferences", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ConferenceParticipants_Participants_ParticipantId", column: x => x.ParticipantId, principalTable: "Participants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MealPlanParticipants", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ParticipantId = table.Column(type: "int", nullable: false), MealPlanId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MealPlanParticipants", x => x.Id); table.ForeignKey( name: "FK_MealPlanParticipants_MealPlans_MealPlanId", column: x => x.MealPlanId, principalTable: "MealPlans", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_MealPlanParticipants_Participants_ParticipantId", column: x => x.ParticipantId, principalTable: "Participants", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "ConferenceBookingDinners", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ConferenceBookingId = table.Column(type: "int", nullable: false), DinnerId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ConferenceBookingDinners", x => x.Id); table.ForeignKey( name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBookingId", column: x => x.ConferenceBookingId, principalTable: "ConferenceBookings", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_ConferenceBookingDinners_Dinners_DinnerId", column: x => x.DinnerId, principalTable: "Dinners", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "RoomDinners", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), RoomId = table.Column(type: "int", nullable: false), DinnerId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_RoomDinners", x => x.Id); table.ForeignKey( name: "FK_RoomDinners_Dinners_DinnerId", column: x => x.DinnerId, principalTable: "Dinners", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_RoomDinners_Rooms_RoomId", column: x => x.RoomId, principalTable: "Rooms", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_ConferenceBookingDinners_ConferenceBookingId", table: "ConferenceBookingDinners", column: "ConferenceBookingId"); migrationBuilder.CreateIndex( name: "IX_ConferenceBookingDinners_DinnerId", table: "ConferenceBookingDinners", column: "DinnerId"); migrationBuilder.CreateIndex( name: "IX_ConferenceBookings_AdministratorId", table: "ConferenceBookings", column: "AdministratorId"); migrationBuilder.CreateIndex( name: "IX_ConferenceBookings_ConferenceId", table: "ConferenceBookings", column: "ConferenceId"); migrationBuilder.CreateIndex( name: "IX_ConferenceParticipants_ConferenceId", table: "ConferenceParticipants", column: "ConferenceId"); migrationBuilder.CreateIndex( name: "IX_ConferenceParticipants_ParticipantId", table: "ConferenceParticipants", column: "ParticipantId"); migrationBuilder.CreateIndex( name: "IX_Conferences_OrganiserId", table: "Conferences", column: "OrganiserId"); migrationBuilder.CreateIndex( name: "IX_Dinners_AdministratorId", table: "Dinners", column: "AdministratorId"); migrationBuilder.CreateIndex( name: "IX_MealPlanParticipants_MealPlanId", table: "MealPlanParticipants", column: "MealPlanId"); migrationBuilder.CreateIndex( name: "IX_MealPlanParticipants_ParticipantId", table: "MealPlanParticipants", column: "ParticipantId"); migrationBuilder.CreateIndex( name: "IX_MealPlans_OrganiserId", table: "MealPlans", column: "OrganiserId"); migrationBuilder.CreateIndex( name: "IX_Participants_OrganiserId", table: "Participants", column: "OrganiserId"); migrationBuilder.CreateIndex( name: "IX_RoomDinners_DinnerId", table: "RoomDinners", column: "DinnerId"); migrationBuilder.CreateIndex( name: "IX_RoomDinners_RoomId", table: "RoomDinners", column: "RoomId"); migrationBuilder.CreateIndex( name: "IX_Rooms_AdministratorId", table: "Rooms", column: "AdministratorId"); migrationBuilder.CreateIndex( name: "IX_Rooms_MealPlanId", table: "Rooms", column: "MealPlanId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ConferenceBookingDinners"); migrationBuilder.DropTable( name: "ConferenceParticipants"); migrationBuilder.DropTable( name: "MealPlanParticipants"); migrationBuilder.DropTable( name: "RoomDinners"); migrationBuilder.DropTable( name: "ConferenceBookings"); migrationBuilder.DropTable( name: "Participants"); migrationBuilder.DropTable( name: "Dinners"); migrationBuilder.DropTable( name: "Rooms"); migrationBuilder.DropTable( name: "Conferences"); migrationBuilder.DropTable( name: "Administrators"); migrationBuilder.DropTable( name: "MealPlans"); migrationBuilder.DropTable( name: "Organisers"); } } }