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: "CleaningInstruments", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Type = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CleaningInstruments", x => x.Id); }); migrationBuilder.CreateTable( name: "Cleanings", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Date = table.Column(type: "datetime2", nullable: false), RoomId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Cleanings", x => x.Id); }); migrationBuilder.CreateTable( name: "Guests", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), SecondName = table.Column(type: "nvarchar(max)", nullable: false), LastName = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Guests", x => x.Id); }); migrationBuilder.CreateTable( name: "Maitres", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Name = table.Column(type: "nvarchar(max)", nullable: false), SecondName = table.Column(type: "nvarchar(max)", nullable: false), LastName = table.Column(type: "nvarchar(max)", nullable: false), Login = table.Column(type: "nvarchar(max)", nullable: false), Password = table.Column(type: "nvarchar(max)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Maitres", x => x.Id); }); migrationBuilder.CreateTable( name: "Reservations", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), StartDate = table.Column(type: "datetime2", nullable: false), EndDate = table.Column(type: "datetime2", nullable: false), GuestId = table.Column(type: "int", nullable: false), MaitreId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Reservations", x => x.Id); }); migrationBuilder.CreateTable( name: "CleaningInstrument", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CleaningId = table.Column(type: "int", nullable: false), CleaningInstrumentsId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_CleaningInstrument", x => x.Id); table.ForeignKey( name: "FK_CleaningInstrument_CleaningInstruments_CleaningInstrumentsId", column: x => x.CleaningInstrumentsId, principalTable: "CleaningInstruments", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_CleaningInstrument_Cleanings_CleaningId", column: x => x.CleaningId, principalTable: "Cleanings", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "Rooms", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Type = table.Column(type: "nvarchar(max)", nullable: false), Cost = table.Column(type: "float", nullable: false), ReservationId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Rooms", x => x.Id); table.ForeignKey( name: "FK_Rooms_Reservations_ReservationId", column: x => x.ReservationId, principalTable: "Reservations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "ReservationRooms", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ReservationId = table.Column(type: "int", nullable: false), RoomId = table.Column(type: "int", nullable: false), RoomId1 = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_ReservationRooms", x => x.Id); table.ForeignKey( name: "FK_ReservationRooms_Reservations_RoomId", column: x => x.RoomId, principalTable: "Reservations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ReservationRooms_Rooms_RoomId1", column: x => x.RoomId1, principalTable: "Rooms", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_CleaningInstrument_CleaningId", table: "CleaningInstrument", column: "CleaningId"); migrationBuilder.CreateIndex( name: "IX_CleaningInstrument_CleaningInstrumentsId", table: "CleaningInstrument", column: "CleaningInstrumentsId"); migrationBuilder.CreateIndex( name: "IX_ReservationRooms_RoomId", table: "ReservationRooms", column: "RoomId"); migrationBuilder.CreateIndex( name: "IX_ReservationRooms_RoomId1", table: "ReservationRooms", column: "RoomId1"); migrationBuilder.CreateIndex( name: "IX_Rooms_ReservationId", table: "Rooms", column: "ReservationId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "CleaningInstrument"); migrationBuilder.DropTable( name: "Guests"); migrationBuilder.DropTable( name: "Maitres"); migrationBuilder.DropTable( name: "ReservationRooms"); migrationBuilder.DropTable( name: "CleaningInstruments"); migrationBuilder.DropTable( name: "Cleanings"); migrationBuilder.DropTable( name: "Rooms"); migrationBuilder.DropTable( name: "Reservations"); } } }