75 lines
3.5 KiB
C#
75 lines
3.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace WhiteLagoon.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class addBookingToDb : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Bookings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
UserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
|
VillaId = table.Column<int>(type: "int", nullable: false),
|
|
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
TotalCost = table.Column<double>(type: "float", nullable: false),
|
|
Nights = table.Column<int>(type: "int", nullable: false),
|
|
Status = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
BookingDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
CheckInDate = table.Column<DateOnly>(type: "date", nullable: false),
|
|
CheckOutDate = table.Column<DateOnly>(type: "date", nullable: false),
|
|
IsPaymentSuccessful = table.Column<bool>(type: "bit", nullable: false),
|
|
PaymentDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
StripeSessionId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
StripePaymentIntentId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
ActualCheckInDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
ActualCheckOutDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
|
VillaNumber = table.Column<int>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Bookings");
|
|
}
|
|
}
|
|
}
|