using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PowderCoating.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class Baseline : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // These UpdateData calls were generated from an existing live database.
            // On a fresh install the PricingTiers table and its seed rows may not exist yet
            // (seeding is manual via Platform Management → Seed Data), so guard each update.
            migrationBuilder.Sql(@"
                IF OBJECT_ID(N'[PricingTiers]', N'U') IS NOT NULL
                BEGIN
                    IF EXISTS (SELECT 1 FROM [PricingTiers] WHERE [Id] = 1)
                        UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T15:49:58.7377851Z' WHERE [Id] = 1;
                    IF EXISTS (SELECT 1 FROM [PricingTiers] WHERE [Id] = 2)
                        UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T15:49:58.7377856Z' WHERE [Id] = 2;
                    IF EXISTS (SELECT 1 FROM [PricingTiers] WHERE [Id] = 3)
                        UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T15:49:58.7377858Z' WHERE [Id] = 3;
                END
            ");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 1,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 16, 14, 27, 16, 805, DateTimeKind.Utc).AddTicks(2839));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 2,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 16, 14, 27, 16, 805, DateTimeKind.Utc).AddTicks(2845));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 3,
                column: "CreatedAt",
                value: new DateTime(2026, 3, 16, 14, 27, 16, 805, DateTimeKind.Utc).AddTicks(2846));
        }
    }
}
