2023-04-07 13:53:08 +04:00

217 lines
8.9 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace HotelDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class init : Migration
{
/// <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);
});
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: "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),
ReservationId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ReservationId = table.Column<int>(type: "int", nullable: false),
RoomId = table.Column<int>(type: "int", nullable: false),
RoomId1 = table.Column<int>(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");
}
/// <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(
name: "Rooms");
migrationBuilder.DropTable(
name: "Reservations");
}
}
}