-- Run this AFTER applying the schema script from the old database.
-- Marks all 43 EF migrations as applied so EF Core won't try to re-run them.

IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL
BEGIN
    CREATE TABLE [__EFMigrationsHistory] (
        [MigrationId] nvarchar(150) NOT NULL,
        [ProductVersion] nvarchar(32) NOT NULL,
        CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
    );
END;

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
SELECT MigrationId, ProductVersion FROM (VALUES
    ('20260316155002_Baseline', '8.0.11'),
    ('20260317121938_AddAiContextProfile', '8.0.11'),
    ('20260317205927_FixLaborItemQuantityDecimal', '8.0.11'),
    ('20260318124847_AddJobTimeEntries', '8.0.11'),
    ('20260318131500_AddJobShopAccessCode', '8.0.11'),
    ('20260318132857_AddShopWorkerRoleCosts', '8.0.11'),
    ('20260318134236_AddReworkTracking', '8.0.11'),
    ('20260318222648_AddRefundsAndCreditMemos', '8.0.11'),
    ('20260319023827_AddJobTemplates', '8.0.11'),
    ('20260319154506_AddGiftCertificates', '8.0.11'),
    ('20260320002450_AddRefundStoreCreditLink', '8.0.11'),
    ('20260320005106_AddQuoteItemIsAiItem', '8.0.11'),
    ('20260320011057_AddQuotePricingSnapshot', '8.0.11'),
    ('20260320231509_AddStripeConnectAndOnlinePayments', '8.0.11'),
    ('20260326230438_AddQuotePhotoSubscriptionLimits', '8.0.11'),
    ('20260328133627_AddJobPhotoIsAiAnalysisPhoto', '8.0.11'),
    ('20260329003300_AddJobDiscountRushFields', '8.0.11'),
    ('20260329005838_AddDeposits', '8.0.11'),
    ('20260329134753_AddMerchandise', '8.0.11'),
    ('20260329141137_AddGiftCertificateInvoiceItems', '8.0.11'),
    ('20260330234034_AddSalesItemFields', '8.0.11'),
    ('20260401125630_AddQuoteDepositPaymentFields', '8.0.11'),
    ('20260401131724_AddUniqueDocumentNumberConstraints', '8.0.11'),
    ('20260401141653_FixGiftCertificateUniqueIndexPerCompany', '8.0.11'),
    ('20260402015422_AddInvoiceExternalReference', '8.0.11'),
    ('20260402032156_AddMigratingFromQuickBooks', '8.0.11'),
    ('20260402165758_AddQbMigrationStateJson', '8.0.11'),
    ('20260402184721_FixInventorySkuUniqueIndex', '8.0.11'),
    ('20260402185216_FixJobShopAccessCodeUniqueIndex', '8.0.11'),
    ('20260402224949_AddDashboardTips', '8.0.11'),
    ('20260403000650_AddStripeWebhookEvents', '8.0.11'),
    ('20260404151636_AddAllowAccountingToPlan', '8.0.11'),
    ('20260404194126_AddBillReceiptFilePath', '8.0.11'),
    ('20260405003350_AddPerformanceIndexes', '8.0.11'),
    ('20260405155653_AddPlatformSettings', '8.0.11'),
    ('20260405161241_AddPlatformSettingsV2', '8.0.11'),
    ('20260405162137_UpdateAdminEmailDescription', '8.0.11'),
    ('20260406191501_MakeBillLineItemAccountIdNullable', '8.0.11'),
    ('20260408205345_AddJobIntakeFields', '8.0.11'),
    ('20260409013822_AddInAppNotifications', '8.0.11'),
    ('20260410021934_AddLegalCompliance', '8.0.11'),
    ('20260410025353_AddAiFeaturesToPlanConfig', '8.0.11'),
    ('20260410032027_AddTrialsEnabledSetting', '8.0.11')
) AS v(MigrationId, ProductVersion)
WHERE NOT EXISTS (
    SELECT 1 FROM [__EFMigrationsHistory] WHERE [MigrationId] = v.MigrationId
);
