using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace HotelDataBaseImplement.Migrations { /// public partial class NewMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Administrators", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), AdministratorFIO = table.Column(type: "text", nullable: false), AdministratorPhone = table.Column(type: "text", nullable: false), AdministratorLogin = table.Column(type: "text", nullable: false), AdministratorPassword = table.Column(type: "text", nullable: false), AdministratorEmail = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Administrators", x => x.Id); }); migrationBuilder.CreateTable( name: "Organisers", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), OrganiserLogin = table.Column(type: "text", nullable: false), OrganiserPassword = table.Column(type: "text", nullable: false), OrganiserEmail = table.Column(type: "text", nullable: false), OrganiserNumber = table.Column(type: "text", nullable: false), OrganiserFIO = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Organisers", x => x.Id); }); migrationBuilder.CreateTable( name: "Dinners", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DinnerName = table.Column(type: "text", nullable: false), DinnerСalorieСontent = table.Column(type: "integer", nullable: false), DinnerPrice = table.Column(type: "double precision", nullable: false), AdministratorId = table.Column(type: "integer", 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: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ConferenceName = table.Column(type: "text", nullable: false), Subject = table.Column(type: "text", nullable: false), OrganiserId = table.Column(type: "integer", 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: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), MealPlanName = table.Column(type: "text", nullable: false), MealPlanPrice = table.Column(type: "double precision", nullable: false), OrganiserId = table.Column(type: "integer", 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: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ParticipantFIO = table.Column(type: "text", nullable: false), Number = table.Column(type: "text", nullable: false), OrganiserId = table.Column(type: "integer", 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: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), DateСonference = table.Column(type: "timestamp without time zone", nullable: true), AdministratorId = table.Column(type: "integer", nullable: false), ConferenceId = table.Column(type: "integer", nullable: true), PlaceСonference = table.Column(type: "text", 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"); }); migrationBuilder.CreateTable( name: "Rooms", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoomNumber = table.Column(type: "integer", nullable: false), CountBeds = table.Column(type: "integer", nullable: false), RoomPrice = table.Column(type: "double precision", nullable: false), AdministratorId = table.Column(type: "integer", nullable: false), MealPlanId = table.Column(type: "integer", 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"); }); migrationBuilder.CreateTable( name: "ConferenceParticipants", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ParticipantId = table.Column(type: "integer", nullable: false), ConferenceId = table.Column(type: "integer", 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.Cascade); 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: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ParticipantId = table.Column(type: "integer", nullable: false), MealPlanId = table.Column(type: "integer", 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.Cascade); table.ForeignKey( name: "FK_MealPlanParticipants_Participants_ParticipantId", column: x => x.ParticipantId, principalTable: "Participants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ConferenceBookingDinners", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ConferenceBookingId = table.Column(type: "integer", nullable: false), DinnerId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_ConferenceBookingDinners", x => x.Id); table.ForeignKey( name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBooki~", column: x => x.ConferenceBookingId, principalTable: "ConferenceBookings", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ConferenceBookingDinners_Dinners_DinnerId", column: x => x.DinnerId, principalTable: "Dinners", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "MealPlanRooms", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoomId = table.Column(type: "integer", nullable: false), MealPlanId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_MealPlanRooms", x => x.Id); table.ForeignKey( name: "FK_MealPlanRooms_MealPlans_MealPlanId", column: x => x.MealPlanId, principalTable: "MealPlans", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_MealPlanRooms_Rooms_RoomId", column: x => x.RoomId, principalTable: "Rooms", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "RoomDinners", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoomId = table.Column(type: "integer", nullable: false), DinnerId = table.Column(type: "integer", 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.Cascade); table.ForeignKey( name: "FK_RoomDinners_Rooms_RoomId", column: x => x.RoomId, principalTable: "Rooms", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); 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_MealPlanRooms_MealPlanId", table: "MealPlanRooms", column: "MealPlanId"); migrationBuilder.CreateIndex( name: "IX_MealPlanRooms_RoomId", table: "MealPlanRooms", column: "RoomId"); 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: "MealPlanRooms"); 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"); } } }