using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace OmsorgCore.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class AddTimeEntryStatusAndSurchargeHours : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Status",
                table: "time_entries");

            migrationBuilder.AddColumn<bool>(
                name: "IsEditableByOwner",
                table: "value_list_items",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "RequiresApproval",
                table: "value_list_item_transitions",
                type: "boolean",
                nullable: false,
                defaultValue: true);

            migrationBuilder.AddColumn<string>(
                name: "AdminNote",
                table: "time_entries",
                type: "character varying(500)",
                maxLength: 500,
                nullable: true);

            migrationBuilder.AddColumn<decimal>(
                name: "HolidayHours",
                table: "time_entries",
                type: "numeric(6,2)",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.AddColumn<decimal>(
                name: "NightHours",
                table: "time_entries",
                type: "numeric(6,2)",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.AddColumn<decimal>(
                name: "SaturdayHours",
                table: "time_entries",
                type: "numeric(6,2)",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.AddColumn<Guid>(
                name: "StatusId",
                table: "time_entries",
                type: "uuid",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddColumn<decimal>(
                name: "SundayHours",
                table: "time_entries",
                type: "numeric(6,2)",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.CreateIndex(
                name: "IX_time_entries_StatusId",
                table: "time_entries",
                column: "StatusId");

            migrationBuilder.AddForeignKey(
                name: "FK_time_entries_value_list_items_StatusId",
                table: "time_entries",
                column: "StatusId",
                principalTable: "value_list_items",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_time_entries_value_list_items_StatusId",
                table: "time_entries");

            migrationBuilder.DropIndex(
                name: "IX_time_entries_StatusId",
                table: "time_entries");

            migrationBuilder.DropColumn(
                name: "IsEditableByOwner",
                table: "value_list_items");

            migrationBuilder.DropColumn(
                name: "RequiresApproval",
                table: "value_list_item_transitions");

            migrationBuilder.DropColumn(
                name: "AdminNote",
                table: "time_entries");

            migrationBuilder.DropColumn(
                name: "HolidayHours",
                table: "time_entries");

            migrationBuilder.DropColumn(
                name: "NightHours",
                table: "time_entries");

            migrationBuilder.DropColumn(
                name: "SaturdayHours",
                table: "time_entries");

            migrationBuilder.DropColumn(
                name: "StatusId",
                table: "time_entries");

            migrationBuilder.DropColumn(
                name: "SundayHours",
                table: "time_entries");

            migrationBuilder.AddColumn<string>(
                name: "Status",
                table: "time_entries",
                type: "character varying(50)",
                maxLength: 50,
                nullable: false,
                defaultValue: "");
        }
    }
}
