using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PowderCoating.Infrastructure.Migrations { /// public partial class AddAiCatalogPriceCheckGating : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "AllowAiCatalogPriceCheck", table: "SubscriptionPlanConfigs", type: "bit", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "AiCatalogPriceCheckEnabled", table: "Companies", type: "bit", nullable: false, defaultValue: false); // Use raw SQL so we don't collide with an existing row — ID 9 may already be // taken in environments where settings were added outside of migrations. migrationBuilder.Sql(""" IF NOT EXISTS (SELECT 1 FROM [PlatformSettings] WHERE [Key] = N'AiCatalogPriceCheckEnabled') BEGIN INSERT INTO [PlatformSettings] ([Key], [Value], [Label], [Description], [GroupName]) VALUES (N'AiCatalogPriceCheckEnabled', N'true', N'AI Catalog Price Check Enabled', N'When true (default), the AI Catalog Price Check feature is available to companies on qualifying plans. Set to false to disable it platform-wide.', N'AI Features'); END """); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 1, column: "CreatedAt", value: new DateTime(2026, 4, 26, 12, 26, 21, 727, DateTimeKind.Utc).AddTicks(5012)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 2, column: "CreatedAt", value: new DateTime(2026, 4, 26, 12, 26, 21, 727, DateTimeKind.Utc).AddTicks(5018)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 3, column: "CreatedAt", value: new DateTime(2026, 4, 26, 12, 26, 21, 727, DateTimeKind.Utc).AddTicks(5020)); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.Sql("DELETE FROM [PlatformSettings] WHERE [Key] = N'AiCatalogPriceCheckEnabled'"); migrationBuilder.DropColumn( name: "AllowAiCatalogPriceCheck", table: "SubscriptionPlanConfigs"); migrationBuilder.DropColumn( name: "AiCatalogPriceCheckEnabled", table: "Companies"); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 1, column: "CreatedAt", value: new DateTime(2026, 4, 25, 22, 34, 50, 1, DateTimeKind.Utc).AddTicks(6987)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 2, column: "CreatedAt", value: new DateTime(2026, 4, 25, 22, 34, 50, 1, DateTimeKind.Utc).AddTicks(6993)); migrationBuilder.UpdateData( table: "PricingTiers", keyColumn: "Id", keyValue: 3, column: "CreatedAt", value: new DateTime(2026, 4, 25, 22, 34, 50, 1, DateTimeKind.Utc).AddTicks(6994)); } } }