164 lines
7.2 KiB
C#
164 lines
7.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace HotelDatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class initialMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Clients",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
Name = table.Column<string>(type: "text", nullable: false),
|
|
Surname = table.Column<string>(type: "text", nullable: false),
|
|
DateOfBirth = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
PhoneNumber = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Posts",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
PostName = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Posts", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Workers",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
PostId = table.Column<int>(type: "integer", nullable: false),
|
|
FIO = table.Column<string>(type: "text", nullable: false),
|
|
DateOfBirth = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
WorkExperience = table.Column<int>(type: "integer", nullable: false),
|
|
Salary = table.Column<int>(type: "integer", nullable: false),
|
|
Phone = table.Column<string>(type: "text", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Workers", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Workers_Posts_PostId",
|
|
column: x => x.PostId,
|
|
principalTable: "Posts",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Rooms",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
WorkerId = table.Column<int>(type: "integer", nullable: false),
|
|
Number = table.Column<int>(type: "integer", nullable: false),
|
|
Floor = table.Column<int>(type: "integer", nullable: false),
|
|
NumberOfBeds = table.Column<int>(type: "integer", nullable: false),
|
|
Condition = table.Column<string>(type: "text", nullable: false),
|
|
Cost = table.Column<int>(type: "integer", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Rooms", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Rooms_Workers_WorkerId",
|
|
column: x => x.WorkerId,
|
|
principalTable: "Workers",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Bookings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
RoomId = table.Column<int>(type: "integer", nullable: false),
|
|
ClientId = table.Column<int>(type: "integer", nullable: false),
|
|
ArrivalDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
DepartureDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
|
NumberHoursSpent = table.Column<double>(type: "double precision", nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
TotalCost = table.Column<double>(type: "double precision", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Bookings", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Bookings_Clients_ClientId",
|
|
column: x => x.ClientId,
|
|
principalTable: "Clients",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
table.ForeignKey(
|
|
name: "FK_Bookings_Rooms_RoomId",
|
|
column: x => x.RoomId,
|
|
principalTable: "Rooms",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Bookings_ClientId",
|
|
table: "Bookings",
|
|
column: "ClientId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Bookings_RoomId",
|
|
table: "Bookings",
|
|
column: "RoomId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Rooms_WorkerId",
|
|
table: "Rooms",
|
|
column: "WorkerId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Workers_PostId",
|
|
table: "Workers",
|
|
column: "PostId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Bookings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Clients");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Rooms");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Workers");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Posts");
|
|
}
|
|
}
|
|
}
|