2023-04-07 13:53:08 +04:00
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace HotelDatabaseImplement.Migrations
|
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
2023-05-19 17:52:18 +04:00
|
|
|
|
public partial class _1 : Migration
|
2023-04-07 13:53:08 +04:00
|
|
|
|
{
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "CleaningInstruments",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Type = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_CleaningInstruments", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Cleanings",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Date = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
|
RoomId = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Cleanings", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Guests",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
SecondName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Guests", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Maitres",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
SecondName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
LastName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Maitres", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Reservations",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
|
EndDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
|
|
|
GuestId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
MaitreId = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Reservations", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-05-19 17:52:18 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "Rooms",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
Type = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
|
|
|
Cost = table.Column<double>(type: "float", nullable: false),
|
|
|
|
|
IsReserved = table.Column<bool>(type: "bit", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_Rooms", x => x.Id);
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-07 13:53:08 +04:00
|
|
|
|
migrationBuilder.CreateTable(
|
|
|
|
|
name: "CleaningInstrument",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
CleaningId = table.Column<int>(type: "int", nullable: false),
|
|
|
|
|
CleaningInstrumentsId = table.Column<int>(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: "ReservationRooms",
|
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
|
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
|
|
|
ReservationId = table.Column<int>(type: "int", nullable: false),
|
2023-05-19 17:52:18 +04:00
|
|
|
|
RoomId = table.Column<int>(type: "int", nullable: false)
|
2023-04-07 13:53:08 +04:00
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
|
|
|
|
table.PrimaryKey("PK_ReservationRooms", x => x.Id);
|
|
|
|
|
table.ForeignKey(
|
2023-05-19 17:52:18 +04:00
|
|
|
|
name: "FK_ReservationRooms_Reservations_ReservationId",
|
|
|
|
|
column: x => x.ReservationId,
|
2023-04-07 13:53:08 +04:00
|
|
|
|
principalTable: "Reservations",
|
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
table.ForeignKey(
|
2023-05-19 17:52:18 +04:00
|
|
|
|
name: "FK_ReservationRooms_Rooms_RoomId",
|
|
|
|
|
column: x => x.RoomId,
|
2023-04-07 13:53:08 +04:00
|
|
|
|
principalTable: "Rooms",
|
2023-05-19 17:52:18 +04:00
|
|
|
|
principalColumn: "Id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
2023-04-07 13:53:08 +04:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_CleaningInstrument_CleaningId",
|
|
|
|
|
table: "CleaningInstrument",
|
|
|
|
|
column: "CleaningId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
|
|
|
|
name: "IX_CleaningInstrument_CleaningInstrumentsId",
|
|
|
|
|
table: "CleaningInstrument",
|
|
|
|
|
column: "CleaningInstrumentsId");
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2023-05-19 17:52:18 +04:00
|
|
|
|
name: "IX_ReservationRooms_ReservationId",
|
2023-04-07 13:53:08 +04:00
|
|
|
|
table: "ReservationRooms",
|
2023-05-19 17:52:18 +04:00
|
|
|
|
column: "ReservationId");
|
2023-04-07 13:53:08 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2023-05-19 17:52:18 +04:00
|
|
|
|
name: "IX_ReservationRooms_RoomId",
|
2023-04-07 13:53:08 +04:00
|
|
|
|
table: "ReservationRooms",
|
2023-05-19 17:52:18 +04:00
|
|
|
|
column: "RoomId");
|
2023-04-07 13:53:08 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
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(
|
2023-05-19 17:52:18 +04:00
|
|
|
|
name: "Reservations");
|
2023-04-07 13:53:08 +04:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2023-05-19 17:52:18 +04:00
|
|
|
|
name: "Rooms");
|
2023-04-07 13:53:08 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|