using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace OmsorgCore.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddFacilityConditionsAndQualificationRates : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "BillingInterval",
                table: "facilities",
                type: "character varying(50)",
                maxLength: 50,
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "BillingRate",
                table: "facilities",
                type: "numeric(10,2)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "BreakPolicy",
                table: "facilities",
                type: "character varying(1000)",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "HolidaySurchargePercent",
                table: "facilities",
                type: "numeric(5,2)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "IndividualAgreements",
                table: "facilities",
                type: "character varying(2000)",
                maxLength: 2000,
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "MinimumHours",
                table: "facilities",
                type: "numeric(5,2)",
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "NightSurchargePercent",
                table: "facilities",
                type: "numeric(5,2)",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "PaymentTermDays",
                table: "facilities",
                type: "integer",
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "SaturdaySurchargePercent",
                table: "facilities",
                type: "numeric(5,2)",
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "SundaySurchargePercent",
                table: "facilities",
                type: "numeric(5,2)",
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "TravelCostRate",
                table: "facilities",
                type: "numeric(10,2)",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "facility_qualification_rates",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    FacilityId = table.Column<Guid>(type: "uuid", nullable: false),
                    Qualification = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
                    Rate = table.Column<decimal>(type: "numeric(10,2)", nullable: false),
                    CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false),
                    DeletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_facility_qualification_rates", x => x.Id);
                    table.ForeignKey(
                        name: "FK_facility_qualification_rates_facilities_FacilityId",
                        column: x => x.FacilityId,
                        principalTable: "facilities",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateIndex(
                name: "IX_facility_qualification_rates_FacilityId",
                table: "facility_qualification_rates",
                column: "FacilityId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "facility_qualification_rates");

            migrationBuilder.DropColumn(
                name: "BillingInterval",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "BillingRate",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "BreakPolicy",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "HolidaySurchargePercent",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "IndividualAgreements",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "MinimumHours",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "NightSurchargePercent",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "PaymentTermDays",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "SaturdaySurchargePercent",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "SundaySurchargePercent",
                table: "facilities");

            migrationBuilder.DropColumn(
                name: "TravelCostRate",
                table: "facilities");
        }
    }
}
