using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace WhiteLagoon.Infrastructure.Migrations
{
///
public partial class addBookingToDb : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Bookings",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column(type: "nvarchar(450)", nullable: false),
VillaId = table.Column(type: "int", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: false),
Email = table.Column(type: "nvarchar(max)", nullable: false),
Phone = table.Column(type: "nvarchar(max)", nullable: true),
TotalCost = table.Column(type: "float", nullable: false),
Nights = table.Column(type: "int", nullable: false),
Status = table.Column(type: "nvarchar(max)", nullable: true),
BookingDate = table.Column(type: "datetime2", nullable: false),
CheckInDate = table.Column(type: "date", nullable: false),
CheckOutDate = table.Column(type: "date", nullable: false),
IsPaymentSuccessful = table.Column(type: "bit", nullable: false),
PaymentDate = table.Column(type: "datetime2", nullable: false),
StripeSessionId = table.Column(type: "nvarchar(max)", nullable: true),
StripePaymentIntentId = table.Column(type: "nvarchar(max)", nullable: true),
ActualCheckInDate = table.Column(type: "datetime2", nullable: false),
ActualCheckOutDate = table.Column(type: "datetime2", nullable: false),
VillaNumber = table.Column(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bookings", x => x.Id);
table.ForeignKey(
name: "FK_Bookings_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Bookings_Villas_VillaId",
column: x => x.VillaId,
principalTable: "Villas",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Bookings_UserId",
table: "Bookings",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Bookings_VillaId",
table: "Bookings",
column: "VillaId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Bookings");
}
}
}