﻿BEGIN TRANSACTION;
GO

ALTER TABLE [OvenCosts] ADD [DefaultCycleMinutes] int NULL;
GO

ALTER TABLE [OvenCosts] ADD [MaxLoadSqFt] decimal(18,2) NULL;
GO

DECLARE @var0 sysname;
SELECT @var0 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[OvenBatches]') AND [c].[name] = N'EquipmentId');
IF @var0 IS NOT NULL EXEC(N'ALTER TABLE [OvenBatches] DROP CONSTRAINT [' + @var0 + '];');
ALTER TABLE [OvenBatches] ALTER COLUMN [EquipmentId] int NULL;
GO

ALTER TABLE [OvenBatches] ADD [OvenCostId] int NULL;
GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-14T23:49:48.2095969Z'
WHERE [Id] = 1;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-14T23:49:48.2095976Z'
WHERE [Id] = 2;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-14T23:49:48.2095977Z'
WHERE [Id] = 3;
SELECT @@ROWCOUNT;

GO

CREATE INDEX [IX_OvenBatches_OvenCostId] ON [OvenBatches] ([OvenCostId]);
GO

ALTER TABLE [OvenBatches] ADD CONSTRAINT [FK_OvenBatches_OvenCosts_OvenCostId] FOREIGN KEY ([OvenCostId]) REFERENCES [OvenCosts] ([Id]) ON DELETE NO ACTION;
GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20260314234951_AddOvenCostCapacityFields', N'8.0.11');
GO

COMMIT;
GO

BEGIN TRANSACTION;
GO

ALTER TABLE [CompanyPreferences] ADD [PaymentReminderDays] nvarchar(max) NOT NULL DEFAULT N'';
GO

ALTER TABLE [CompanyPreferences] ADD [PaymentRemindersEnabled] bit NOT NULL DEFAULT CAST(0 AS bit);
GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T01:01:30.3382335Z'
WHERE [Id] = 1;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T01:01:30.3382342Z'
WHERE [Id] = 2;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T01:01:30.3382345Z'
WHERE [Id] = 3;
SELECT @@ROWCOUNT;

GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20260316010133_AddPaymentReminderPreferences', N'8.0.11');
GO

COMMIT;
GO

BEGIN TRANSACTION;
GO

ALTER TABLE [JobItems] DROP CONSTRAINT [FK_JobItems_InventoryItems_PowderInventoryId];
GO

DROP INDEX [IX_JobItems_PowderInventoryId] ON [JobItems];
GO

DECLARE @var1 sysname;
SELECT @var1 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[JobItems]') AND [c].[name] = N'PowderInventoryId');
IF @var1 IS NOT NULL EXEC(N'ALTER TABLE [JobItems] DROP CONSTRAINT [' + @var1 + '];');
ALTER TABLE [JobItems] DROP COLUMN [PowderInventoryId];
GO

DECLARE @var2 sysname;
SELECT @var2 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Equipment]') AND [c].[name] = N'MaxCureTemperatureF');
IF @var2 IS NOT NULL EXEC(N'ALTER TABLE [Equipment] DROP CONSTRAINT [' + @var2 + '];');
ALTER TABLE [Equipment] DROP COLUMN [MaxCureTemperatureF];
GO

DECLARE @var3 sysname;
SELECT @var3 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Equipment]') AND [c].[name] = N'MaxLoadWeightLbs');
IF @var3 IS NOT NULL EXEC(N'ALTER TABLE [Equipment] DROP CONSTRAINT [' + @var3 + '];');
ALTER TABLE [Equipment] DROP COLUMN [MaxLoadWeightLbs];
GO

DECLARE @var4 sysname;
SELECT @var4 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Equipment]') AND [c].[name] = N'MinCureTemperatureF');
IF @var4 IS NOT NULL EXEC(N'ALTER TABLE [Equipment] DROP CONSTRAINT [' + @var4 + '];');
ALTER TABLE [Equipment] DROP COLUMN [MinCureTemperatureF];
GO

DECLARE @var5 sysname;
SELECT @var5 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[Companies]') AND [c].[name] = N'Settings');
IF @var5 IS NOT NULL EXEC(N'ALTER TABLE [Companies] DROP CONSTRAINT [' + @var5 + '];');
ALTER TABLE [Companies] DROP COLUMN [Settings];
GO

DECLARE @var6 sysname;
SELECT @var6 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AspNetUsers]') AND [c].[name] = N'DateOfBirth');
IF @var6 IS NOT NULL EXEC(N'ALTER TABLE [AspNetUsers] DROP CONSTRAINT [' + @var6 + '];');
ALTER TABLE [AspNetUsers] DROP COLUMN [DateOfBirth];
GO

DECLARE @var7 sysname;
SELECT @var7 = [d].[name]
FROM [sys].[default_constraints] [d]
INNER JOIN [sys].[columns] [c] ON [d].[parent_column_id] = [c].[column_id] AND [d].[parent_object_id] = [c].[object_id]
WHERE ([d].[parent_object_id] = OBJECT_ID(N'[AspNetUsers]') AND [c].[name] = N'HourlyRate');
IF @var7 IS NOT NULL EXEC(N'ALTER TABLE [AspNetUsers] DROP CONSTRAINT [' + @var7 + '];');
ALTER TABLE [AspNetUsers] DROP COLUMN [HourlyRate];
GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T03:02:22.2139898Z'
WHERE [Id] = 1;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T03:02:22.2139905Z'
WHERE [Id] = 2;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T03:02:22.2139908Z'
WHERE [Id] = 3;
SELECT @@ROWCOUNT;

GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20260316030225_RemoveOrphanedColumns', N'8.0.11');
GO

COMMIT;
GO

BEGIN TRANSACTION;
GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T04:02:52.5982681Z'
WHERE [Id] = 1;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T04:02:52.5982692Z'
WHERE [Id] = 2;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T04:02:52.5982693Z'
WHERE [Id] = 3;
SELECT @@ROWCOUNT;

GO

CREATE INDEX [IX_Quotes_CompanyId_IsDeleted] ON [Quotes] ([CompanyId], [IsDeleted]);
GO

CREATE INDEX [IX_Quotes_ExpirationDate] ON [Quotes] ([ExpirationDate]);
GO

CREATE INDEX [IX_Payments_PaymentDate] ON [Payments] ([PaymentDate]);
GO

CREATE INDEX [IX_OvenBatches_ScheduledDate_Status] ON [OvenBatches] ([ScheduledDate], [Status]);
GO

CREATE INDEX [IX_MaintenanceRecords_ScheduledDate] ON [MaintenanceRecords] ([ScheduledDate]);
GO

CREATE INDEX [IX_MaintenanceRecords_Status] ON [MaintenanceRecords] ([Status]);
GO

CREATE INDEX [IX_Jobs_CompanyId_IsDeleted] ON [Jobs] ([CompanyId], [IsDeleted]);
GO

CREATE INDEX [IX_Jobs_DueDate] ON [Jobs] ([DueDate]);
GO

CREATE INDEX [IX_Jobs_ScheduledDate] ON [Jobs] ([ScheduledDate]);
GO

CREATE INDEX [IX_Invoices_CompanyId_IsDeleted] ON [Invoices] ([CompanyId], [IsDeleted]);
GO

CREATE INDEX [IX_Invoices_DueDate] ON [Invoices] ([DueDate]);
GO

CREATE INDEX [IX_Invoices_InvoiceDate] ON [Invoices] ([InvoiceDate]);
GO

CREATE INDEX [IX_Invoices_Status] ON [Invoices] ([Status]);
GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20260316040255_AddPerformanceIndexesV2', N'8.0.11');
GO

COMMIT;
GO

BEGIN TRANSACTION;
GO

ALTER TABLE [CompanyPreferences] ADD [InAccentColor] nvarchar(max) NOT NULL DEFAULT N'';
GO

ALTER TABLE [CompanyPreferences] ADD [InDefaultTerms] nvarchar(max) NULL;
GO

ALTER TABLE [CompanyPreferences] ADD [InFooterNote] nvarchar(max) NULL;
GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T12:42:13.7414482Z'
WHERE [Id] = 1;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T12:42:13.7414534Z'
WHERE [Id] = 2;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T12:42:13.7414536Z'
WHERE [Id] = 3;
SELECT @@ROWCOUNT;

GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20260316124217_AddInvoicePdfTemplate', N'8.0.11');
GO

COMMIT;
GO

BEGIN TRANSACTION;
GO

ALTER TABLE [BugReports] ADD [CompanyName] nvarchar(max) NULL;
GO

CREATE TABLE [BugReportAttachments] (
    [Id] int NOT NULL IDENTITY,
    [BugReportId] int NOT NULL,
    [BlobPath] nvarchar(max) NOT NULL,
    [FileName] nvarchar(max) NOT NULL,
    [ContentType] nvarchar(max) NOT NULL,
    [FileSizeBytes] bigint NOT NULL,
    [CompanyId] int NOT NULL,
    [CreatedAt] datetime2 NOT NULL,
    [UpdatedAt] datetime2 NULL,
    [CreatedBy] nvarchar(max) NULL,
    [UpdatedBy] nvarchar(max) NULL,
    [IsDeleted] bit NOT NULL,
    [DeletedAt] datetime2 NULL,
    [DeletedBy] nvarchar(max) NULL,
    CONSTRAINT [PK_BugReportAttachments] PRIMARY KEY ([Id]),
    CONSTRAINT [FK_BugReportAttachments_BugReports_BugReportId] FOREIGN KEY ([BugReportId]) REFERENCES [BugReports] ([Id]) ON DELETE CASCADE
);
GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T14:27:16.8052839Z'
WHERE [Id] = 1;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T14:27:16.8052845Z'
WHERE [Id] = 2;
SELECT @@ROWCOUNT;

GO

UPDATE [PricingTiers] SET [CreatedAt] = '2026-03-16T14:27:16.8052846Z'
WHERE [Id] = 3;
SELECT @@ROWCOUNT;

GO

CREATE INDEX [IX_BugReportAttachments_BugReportId] ON [BugReportAttachments] ([BugReportId]);
GO

INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES (N'20260316142720_AddBugReportAttachments', N'8.0.11');
GO

COMMIT;
GO

