using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PowderCoating.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class AddGiftCertificateInvoiceItems : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<DateTime>(
                name: "GcExpiryDate",
                table: "InvoiceItems",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "GcRecipientEmail",
                table: "InvoiceItems",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "GcRecipientName",
                table: "InvoiceItems",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "GeneratedGiftCertificateId",
                table: "InvoiceItems",
                type: "int",
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsGiftCertificate",
                table: "InvoiceItems",
                type: "bit",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<int>(
                name: "SourceInvoiceItemId",
                table: "GiftCertificates",
                type: "int",
                nullable: true);

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 1,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 29, 14, 11, 34, 230, DateTimeKind.Utc).AddTicks(5437));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 2,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 29, 14, 11, 34, 230, DateTimeKind.Utc).AddTicks(5443));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 3,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 29, 14, 11, 34, 230, DateTimeKind.Utc).AddTicks(5445));

            migrationBuilder.CreateIndex(
                name: "IX_InvoiceItems_GeneratedGiftCertificateId",
                table: "InvoiceItems",
                column: "GeneratedGiftCertificateId");

            migrationBuilder.AddForeignKey(
                name: "FK_InvoiceItems_GiftCertificates_GeneratedGiftCertificateId",
                table: "InvoiceItems",
                column: "GeneratedGiftCertificateId",
                principalTable: "GiftCertificates",
                principalColumn: "Id");
        }

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

            migrationBuilder.DropIndex(
                name: "IX_InvoiceItems_GeneratedGiftCertificateId",
                table: "InvoiceItems");

            migrationBuilder.DropColumn(
                name: "GcExpiryDate",
                table: "InvoiceItems");

            migrationBuilder.DropColumn(
                name: "GcRecipientEmail",
                table: "InvoiceItems");

            migrationBuilder.DropColumn(
                name: "GcRecipientName",
                table: "InvoiceItems");

            migrationBuilder.DropColumn(
                name: "GeneratedGiftCertificateId",
                table: "InvoiceItems");

            migrationBuilder.DropColumn(
                name: "IsGiftCertificate",
                table: "InvoiceItems");

            migrationBuilder.DropColumn(
                name: "SourceInvoiceItemId",
                table: "GiftCertificates");

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 1,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 29, 13, 47, 49, 417, DateTimeKind.Utc).AddTicks(6542));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 2,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 29, 13, 47, 49, 417, DateTimeKind.Utc).AddTicks(6549));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 3,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 29, 13, 47, 49, 417, DateTimeKind.Utc).AddTicks(6551));
        }
    }
}
