using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Baya.Infrastructure.Persistence.Migrations
{
    /// <inheritdoc />
    public partial class RefinementPhase6MoneyFks : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DeleteData(
                schema: "ops",
                table: "PlatformConfigs",
                keyColumn: "Id",
                keyValue: 19L);

            migrationBuilder.CreateIndex(
                name: "IX_Invoices_PartnerCenterId",
                schema: "payments",
                table: "Invoices",
                column: "PartnerCenterId");

            migrationBuilder.AddForeignKey(
                name: "FK_Invoices_PartnerCenters_PartnerCenterId",
                schema: "payments",
                table: "Invoices",
                column: "PartnerCenterId",
                principalSchema: "partner",
                principalTable: "PartnerCenters",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_NurseClawbacks_NursePayouts_OriginalPayoutId",
                schema: "payments",
                table: "NurseClawbacks",
                column: "OriginalPayoutId",
                principalSchema: "payouts",
                principalTable: "NursePayouts",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_NurseClawbacks_NursePayouts_RecoveredInPayoutId",
                schema: "payments",
                table: "NurseClawbacks",
                column: "RecoveredInPayoutId",
                principalSchema: "payouts",
                principalTable: "NursePayouts",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_Refunds_Tickets_TicketId",
                schema: "payments",
                table: "Refunds",
                column: "TicketId",
                principalSchema: "messaging",
                principalTable: "Tickets",
                principalColumn: "Id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_Invoices_PartnerCenters_PartnerCenterId",
                schema: "payments",
                table: "Invoices");

            migrationBuilder.DropForeignKey(
                name: "FK_NurseClawbacks_NursePayouts_OriginalPayoutId",
                schema: "payments",
                table: "NurseClawbacks");

            migrationBuilder.DropForeignKey(
                name: "FK_NurseClawbacks_NursePayouts_RecoveredInPayoutId",
                schema: "payments",
                table: "NurseClawbacks");

            migrationBuilder.DropForeignKey(
                name: "FK_Refunds_Tickets_TicketId",
                schema: "payments",
                table: "Refunds");

            migrationBuilder.DropIndex(
                name: "IX_Invoices_PartnerCenterId",
                schema: "payments",
                table: "Invoices");

            migrationBuilder.InsertData(
                schema: "ops",
                table: "PlatformConfigs",
                columns: new[] { "Id", "CreatedAt", "CreatedById", "DataType", "Description", "Key", "ModifiedAt", "ModifiedById", "Value" },
                values: new object[] { 19L, new DateTimeOffset(new DateTime(2026, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "bool", "Whether a refund must link a support ticket (b11). Off until b15 ships the tickets table.", "refund_ticket_required", null, null, "false" });
        }
    }
}
