using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PowderCoating.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class AddCompanyDefaultGlAccounts : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "DefaultCogsAccountId",
                table: "CompanyPreferences",
                type: "int",
                nullable: true);

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

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

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 1,
                column: "CreatedAt",
                value: new DateTime(2026, 6, 20, 13, 49, 14, 564, DateTimeKind.Utc).AddTicks(4507));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 2,
                column: "CreatedAt",
                value: new DateTime(2026, 6, 20, 13, 49, 14, 564, DateTimeKind.Utc).AddTicks(4514));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 3,
                column: "CreatedAt",
                value: new DateTime(2026, 6, 20, 13, 49, 14, 564, DateTimeKind.Utc).AddTicks(4515));

            migrationBuilder.CreateIndex(
                name: "IX_CompanyPreferences_DefaultCogsAccountId",
                table: "CompanyPreferences",
                column: "DefaultCogsAccountId");

            migrationBuilder.CreateIndex(
                name: "IX_CompanyPreferences_DefaultInventoryAccountId",
                table: "CompanyPreferences",
                column: "DefaultInventoryAccountId");

            migrationBuilder.CreateIndex(
                name: "IX_CompanyPreferences_DefaultRevenueAccountId",
                table: "CompanyPreferences",
                column: "DefaultRevenueAccountId");

            migrationBuilder.AddForeignKey(
                name: "FK_CompanyPreferences_Accounts_DefaultCogsAccountId",
                table: "CompanyPreferences",
                column: "DefaultCogsAccountId",
                principalTable: "Accounts",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_CompanyPreferences_Accounts_DefaultInventoryAccountId",
                table: "CompanyPreferences",
                column: "DefaultInventoryAccountId",
                principalTable: "Accounts",
                principalColumn: "Id");

            migrationBuilder.AddForeignKey(
                name: "FK_CompanyPreferences_Accounts_DefaultRevenueAccountId",
                table: "CompanyPreferences",
                column: "DefaultRevenueAccountId",
                principalTable: "Accounts",
                principalColumn: "Id");
        }

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

            migrationBuilder.DropForeignKey(
                name: "FK_CompanyPreferences_Accounts_DefaultInventoryAccountId",
                table: "CompanyPreferences");

            migrationBuilder.DropForeignKey(
                name: "FK_CompanyPreferences_Accounts_DefaultRevenueAccountId",
                table: "CompanyPreferences");

            migrationBuilder.DropIndex(
                name: "IX_CompanyPreferences_DefaultCogsAccountId",
                table: "CompanyPreferences");

            migrationBuilder.DropIndex(
                name: "IX_CompanyPreferences_DefaultInventoryAccountId",
                table: "CompanyPreferences");

            migrationBuilder.DropIndex(
                name: "IX_CompanyPreferences_DefaultRevenueAccountId",
                table: "CompanyPreferences");

            migrationBuilder.DropColumn(
                name: "DefaultCogsAccountId",
                table: "CompanyPreferences");

            migrationBuilder.DropColumn(
                name: "DefaultInventoryAccountId",
                table: "CompanyPreferences");

            migrationBuilder.DropColumn(
                name: "DefaultRevenueAccountId",
                table: "CompanyPreferences");

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 1,
                column: "CreatedAt",
                value: new DateTime(2026, 6, 20, 0, 29, 46, 909, DateTimeKind.Utc).AddTicks(3976));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 2,
                column: "CreatedAt",
                value: new DateTime(2026, 6, 20, 0, 29, 46, 909, DateTimeKind.Utc).AddTicks(3981));

            migrationBuilder.UpdateData(
                table: "PricingTiers",
                keyColumn: "Id",
                keyValue: 3,
                column: "CreatedAt",
                value: new DateTime(2026, 6, 20, 0, 29, 46, 909, DateTimeKind.Utc).AddTicks(3982));
        }
    }
}
