diff --git a/src/PowderCoating.Infrastructure/Migrations/20260426122625_AddAiCatalogPriceCheckGating.cs b/src/PowderCoating.Infrastructure/Migrations/20260426122625_AddAiCatalogPriceCheckGating.cs index 741473c..c7ec2d3 100644 --- a/src/PowderCoating.Infrastructure/Migrations/20260426122625_AddAiCatalogPriceCheckGating.cs +++ b/src/PowderCoating.Infrastructure/Migrations/20260426122625_AddAiCatalogPriceCheckGating.cs @@ -25,15 +25,17 @@ namespace PowderCoating.Infrastructure.Migrations nullable: false, defaultValue: false); - migrationBuilder.InsertData( - table: "PlatformSettings", - columns: ["Id", "Key", "Value", "Label", "Description", "GroupName"], - values: new object[,] - { - { 9, "AiCatalogPriceCheckEnabled", "true", "AI Catalog Price Check Enabled", - "When true (default), the AI Catalog Price Check feature is available to companies on qualifying plans. Set to false to disable it platform-wide.", - "AI Features" } - }); + // 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", @@ -60,10 +62,7 @@ namespace PowderCoating.Infrastructure.Migrations /// protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.DeleteData( - table: "PlatformSettings", - keyColumn: "Id", - keyValue: 9); + migrationBuilder.Sql("DELETE FROM [PlatformSettings] WHERE [Key] = N'AiCatalogPriceCheckEnabled'"); migrationBuilder.DropColumn( name: "AllowAiCatalogPriceCheck",