using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace HotelDatabaseImplement.Migrations { /// public partial class initialMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Clients", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Surname = table.Column(type: "text", nullable: false), DateOfBirth = table.Column(type: "timestamp without time zone", nullable: false), PhoneNumber = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Clients", x => x.Id); }); migrationBuilder.CreateTable( name: "Posts", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), PostName = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Posts", x => x.Id); }); migrationBuilder.CreateTable( name: "Workers", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), PostId = table.Column(type: "integer", nullable: false), FIO = table.Column(type: "text", nullable: false), DateOfBirth = table.Column(type: "timestamp without time zone", nullable: false), WorkExperience = table.Column(type: "integer", nullable: false), Salary = table.Column(type: "integer", nullable: false), Phone = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), WorkerId = table.Column(type: "integer", nullable: false), Number = table.Column(type: "integer", nullable: false), Floor = table.Column(type: "integer", nullable: false), NumberOfBeds = table.Column(type: "integer", nullable: false), Condition = table.Column(type: "text", nullable: false), Cost = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), RoomId = table.Column(type: "integer", nullable: false), ClientId = table.Column(type: "integer", nullable: false), ArrivalDate = table.Column(type: "timestamp without time zone", nullable: false), DepartureDate = table.Column(type: "timestamp without time zone", nullable: false), NumberHoursSpent = table.Column(type: "double precision", nullable: false), Status = table.Column(type: "integer", nullable: false), TotalCost = table.Column(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"); } /// 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"); } } }