2024-05-29 12:33:22 +04:00

417 lines
18 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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: "Administrators",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AdministratorFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
AdministratorPhone = table.Column<string>(type: "nvarchar(max)", nullable: false),
AdministratorLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
AdministratorPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
AdministratorEmail = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Administrators", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Organisers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrganiserLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserFIO = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Organisers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Dinners",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DinnerName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DinnerСalorieСontent = table.Column<int>(type: "int", nullable: false),
DinnerPrice = table.Column<double>(type: "float", nullable: false),
AdministratorId = table.Column<int>(type: "int", 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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ConferenceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
OrganiserId = table.Column<int>(type: "int", 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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MealPlanName = table.Column<string>(type: "nvarchar(max)", nullable: false),
MealPlanPrice = table.Column<double>(type: "float", nullable: false),
OrganiserId = table.Column<int>(type: "int", 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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ParticipantFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Number = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserId = table.Column<int>(type: "int", 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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
DateСonference = table.Column<DateTime>(type: "datetime2", nullable: true),
AdministratorId = table.Column<int>(type: "int", nullable: false),
ConferenceId = table.Column<int>(type: "int", nullable: true),
PlaceСonference = table.Column<string>(type: "nvarchar(max)", 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",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Rooms",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RoomNumber = table.Column<int>(type: "int", nullable: false),
RoomPrice = table.Column<double>(type: "float", nullable: false),
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
AdministratorId = table.Column<int>(type: "int", nullable: false),
MealPlanId = table.Column<int>(type: "int", 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",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ConferenceParticipants",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ParticipantId = table.Column<int>(type: "int", nullable: false),
ConferenceId = table.Column<int>(type: "int", 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.Restrict);
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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ParticipantId = table.Column<int>(type: "int", nullable: false),
MealPlanId = table.Column<int>(type: "int", 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.Restrict);
table.ForeignKey(
name: "FK_MealPlanParticipants_Participants_ParticipantId",
column: x => x.ParticipantId,
principalTable: "Participants",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ConferenceBookingDinners",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ConferenceBookingId = table.Column<int>(type: "int", nullable: false),
DinnerId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ConferenceBookingDinners", x => x.Id);
table.ForeignKey(
name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBookingId",
column: x => x.ConferenceBookingId,
principalTable: "ConferenceBookings",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ConferenceBookingDinners_Dinners_DinnerId",
column: x => x.DinnerId,
principalTable: "Dinners",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "RoomDinners",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RoomId = table.Column<int>(type: "int", nullable: false),
DinnerId = table.Column<int>(type: "int", 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.Restrict);
table.ForeignKey(
name: "FK_RoomDinners_Rooms_RoomId",
column: x => x.RoomId,
principalTable: "Rooms",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
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_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");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ConferenceBookingDinners");
migrationBuilder.DropTable(
name: "ConferenceParticipants");
migrationBuilder.DropTable(
name: "MealPlanParticipants");
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");
}
}
}