using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace PowderCoating.Infrastructure.Migrations
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AccountNumber = table.Column(type: "nvarchar(max)", nullable: false),
Name = table.Column(type: "nvarchar(max)", nullable: false),
AccountType = table.Column(type: "int", nullable: false),
AccountSubType = table.Column(type: "int", nullable: false),
Description = table.Column(type: "nvarchar(max)", nullable: true),
ParentAccountId = table.Column(type: "int", nullable: true),
IsSystem = table.Column(type: "bit", nullable: false),
IsActive = table.Column(type: "bit", nullable: false),
OpeningBalance = table.Column(type: "decimal(18,2)", nullable: false),
OpeningBalanceDate = table.Column(type: "datetime2", nullable: true),
CurrentBalance = table.Column(type: "decimal(18,2)", nullable: false),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
table.ForeignKey(
name: "FK_Accounts_Accounts_ParentAccountId",
column: x => x.ParentAccountId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "AiItemPredictions",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PredictedSurfaceAreaSqFt = table.Column(type: "decimal(18,2)", nullable: false),
PredictedMinutes = table.Column(type: "int", nullable: false),
PredictedComplexity = table.Column(type: "nvarchar(max)", nullable: false),
PredictedUnitPrice = table.Column(type: "decimal(18,2)", nullable: false),
Confidence = table.Column(type: "nvarchar(max)", nullable: false),
Reasoning = table.Column(type: "nvarchar(max)", nullable: true),
AiTags = table.Column(type: "nvarchar(max)", nullable: true),
ConversationRounds = table.Column(type: "int", nullable: false),
UserOverrodeEstimate = table.Column(type: "bit", nullable: false),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AiItemPredictions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Announcements",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column(type: "nvarchar(max)", nullable: false),
Message = table.Column(type: "nvarchar(max)", nullable: false),
Type = table.Column(type: "nvarchar(max)", nullable: false),
Target = table.Column(type: "nvarchar(max)", nullable: false),
TargetPlan = table.Column(type: "int", nullable: true),
TargetCompanyId = table.Column(type: "int", nullable: true),
StartsAt = table.Column(type: "datetime2", nullable: false),
ExpiresAt = table.Column(type: "datetime2", nullable: true),
IsDismissible = table.Column(type: "bit", nullable: false),
IsActive = table.Column(type: "bit", nullable: false),
CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false),
CreatedByUserName = table.Column(type: "nvarchar(max)", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Announcements", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AppointmentStatusLookups",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
StatusCode = table.Column(type: "nvarchar(max)", nullable: false),
DisplayName = table.Column(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column(type: "int", nullable: false),
ColorClass = table.Column(type: "nvarchar(max)", nullable: false),
IconClass = table.Column(type: "nvarchar(max)", nullable: true),
IsActive = table.Column(type: "bit", nullable: false),
IsSystemDefined = table.Column(type: "bit", nullable: false),
IsTerminalStatus = table.Column(type: "bit", nullable: false),
Description = table.Column(type: "nvarchar(max)", nullable: true),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AppointmentStatusLookups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AppointmentTypeLookups",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TypeCode = table.Column(type: "nvarchar(max)", nullable: false),
DisplayName = table.Column(type: "nvarchar(max)", nullable: false),
DisplayOrder = table.Column(type: "int", nullable: false),
ColorClass = table.Column(type: "nvarchar(max)", nullable: false),
IconClass = table.Column(type: "nvarchar(max)", nullable: true),
RequiresJobLink = table.Column(type: "bit", nullable: false),
IsActive = table.Column(type: "bit", nullable: false),
IsSystemDefined = table.Column(type: "bit", nullable: false),
Description = table.Column(type: "nvarchar(max)", nullable: true),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AppointmentTypeLookups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column(type: "nvarchar(450)", nullable: false),
Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AuditLogs",
columns: table => new
{
Id = table.Column(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column(type: "nvarchar(max)", nullable: true),
UserName = table.Column(type: "nvarchar(max)", nullable: false),
CompanyId = table.Column(type: "int", nullable: true),
CompanyName = table.Column(type: "nvarchar(max)", nullable: true),
Action = table.Column(type: "nvarchar(max)", nullable: false),
EntityType = table.Column(type: "nvarchar(450)", nullable: false),
EntityId = table.Column(type: "nvarchar(450)", nullable: true),
EntityDescription = table.Column(type: "nvarchar(max)", nullable: true),
OldValues = table.Column(type: "nvarchar(max)", nullable: true),
NewValues = table.Column(type: "nvarchar(max)", nullable: true),
IpAddress = table.Column(type: "nvarchar(max)", nullable: true),
Timestamp = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AuditLogs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BannedIps",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
IpAddress = table.Column(type: "nvarchar(max)", nullable: false),
Reason = table.Column(type: "nvarchar(max)", nullable: true),
BannedByUserId = table.Column(type: "nvarchar(max)", nullable: true),
BannedAt = table.Column(type: "datetime2", nullable: false),
ExpiresAt = table.Column(type: "datetime2", nullable: true),
IsActive = table.Column(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BannedIps", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Budgets",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column(type: "nvarchar(max)", nullable: false),
FiscalYear = table.Column(type: "int", nullable: false),
Notes = table.Column(type: "nvarchar(max)", nullable: true),
IsDefault = table.Column(type: "bit", nullable: false),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Budgets", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BugReports",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column(type: "nvarchar(max)", nullable: false),
Description = table.Column(type: "nvarchar(max)", nullable: false),
SubmittedByUserId = table.Column(type: "nvarchar(max)", nullable: false),
SubmittedByUserName = table.Column(type: "nvarchar(max)", nullable: false),
CompanyName = table.Column(type: "nvarchar(max)", nullable: true),
Priority = table.Column(type: "int", nullable: false),
Status = table.Column(type: "int", nullable: false),
ResolutionNotes = table.Column(type: "nvarchar(max)", nullable: true),
ResolvedAt = table.Column(type: "datetime2", nullable: true),
ResolvedBy = table.Column(type: "nvarchar(max)", nullable: true),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_BugReports", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CatalogPriceCheckReports",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RunAt = table.Column(type: "datetime2", nullable: false),
ItemsChecked = table.Column(type: "int", nullable: false),
ResultsJson = table.Column(type: "nvarchar(max)", nullable: false),
OperatingCostsSummary = table.Column(type: "nvarchar(max)", nullable: false),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CatalogPriceCheckReports", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Companies",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CompanyName = table.Column(type: "nvarchar(max)", nullable: false),
CompanyCode = table.Column(type: "nvarchar(450)", nullable: true),
PrimaryContactName = table.Column(type: "nvarchar(max)", nullable: false),
PrimaryContactEmail = table.Column(type: "nvarchar(max)", nullable: false),
Phone = table.Column(type: "nvarchar(max)", nullable: true),
Address = table.Column(type: "nvarchar(max)", nullable: true),
City = table.Column(type: "nvarchar(max)", nullable: true),
State = table.Column(type: "nvarchar(max)", nullable: true),
ZipCode = table.Column(type: "nvarchar(max)", nullable: true),
IsActive = table.Column(type: "bit", nullable: false),
SubscriptionStartDate = table.Column(type: "datetime2", nullable: false),
SubscriptionEndDate = table.Column(type: "datetime2", nullable: true),
SubscriptionPlan = table.Column(type: "int", nullable: false),
SubscriptionStatus = table.Column(type: "int", nullable: false),
StripeCustomerId = table.Column(type: "nvarchar(max)", nullable: true),
StripeSubscriptionId = table.Column(type: "nvarchar(max)", nullable: true),
IsComped = table.Column(type: "bit", nullable: false),
StripeAccountId = table.Column(type: "nvarchar(max)", nullable: true),
StripeConnectStatus = table.Column(type: "int", nullable: false),
OnlinePaymentSurchargeType = table.Column(type: "int", nullable: false),
OnlinePaymentSurchargeValue = table.Column(type: "decimal(18,2)", nullable: false),
OnlineSurchargeAcknowledged = table.Column(type: "bit", nullable: false),
SubscriptionNotes = table.Column(type: "nvarchar(max)", nullable: true),
MaxUsersOverride = table.Column(type: "int", nullable: true),
MaxActiveJobsOverride = table.Column(type: "int", nullable: true),
MaxCustomersOverride = table.Column(type: "int", nullable: true),
MaxQuotesOverride = table.Column(type: "int", nullable: true),
MaxCatalogItemsOverride = table.Column(type: "int", nullable: true),
MaxJobPhotosOverride = table.Column(type: "int", nullable: true),
MaxQuotePhotosOverride = table.Column(type: "int", nullable: true),
MaxAiPhotoQuotesPerMonthOverride = table.Column(type: "int", nullable: true),
AiPhotoQuotesEnabled = table.Column(type: "bit", nullable: false),
AiInventoryAssistEnabled = table.Column(type: "bit", nullable: false),
AiCatalogPriceCheckEnabled = table.Column(type: "bit", nullable: false),
IsAnnualBilling = table.Column(type: "bit", nullable: false),
OnlinePaymentsOverride = table.Column(type: "bit", nullable: true),
AccountingOverride = table.Column(type: "bit", nullable: true),
SmsEnabled = table.Column(type: "bit", nullable: false),
SmsDisabledByAdmin = table.Column(type: "bit", nullable: false),
MarketingEmailOptOut = table.Column(type: "bit", nullable: false),
MarketingUnsubscribeToken = table.Column(type: "nvarchar(max)", nullable: false),
AccountingMethod = table.Column(type: "int", nullable: false),
BookLockedThrough = table.Column(type: "datetime2", nullable: true),
TimeZone = table.Column(type: "nvarchar(max)", nullable: true),
LogoData = table.Column(type: "varbinary(max)", nullable: true),
LogoContentType = table.Column(type: "nvarchar(max)", nullable: true),
LogoFilePath = table.Column(type: "nvarchar(max)", nullable: true),
KioskActivationToken = table.Column(type: "nvarchar(max)", nullable: true),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Companies", x => x.Id);
});
migrationBuilder.CreateTable(
name: "CompanySmsAgreements",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AgreedByUserId = table.Column(type: "nvarchar(max)", nullable: false),
AgreedByUserName = table.Column(type: "nvarchar(max)", nullable: false),
AgreedAt = table.Column(type: "datetime2", nullable: false),
IpAddress = table.Column(type: "nvarchar(max)", nullable: true),
UserAgent = table.Column(type: "nvarchar(max)", nullable: true),
TermsVersion = table.Column(type: "nvarchar(max)", nullable: false),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CompanySmsAgreements", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ContactSubmissions",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SenderName = table.Column(type: "nvarchar(max)", nullable: false),
SenderEmail = table.Column(type: "nvarchar(max)", nullable: false),
CompanyName = table.Column(type: "nvarchar(max)", nullable: false),
Category = table.Column(type: "nvarchar(max)", nullable: false),
Subject = table.Column(type: "nvarchar(max)", nullable: false),
Message = table.Column(type: "nvarchar(max)", nullable: false),
IsRead = table.Column(type: "bit", nullable: false),
ReadAt = table.Column(type: "datetime2", nullable: true),
ReadByUserId = table.Column(type: "nvarchar(max)", nullable: true),
ReadByUserName = table.Column(type: "nvarchar(max)", nullable: true),
AdminNotes = table.Column(type: "nvarchar(max)", nullable: true),
CompanyId = table.Column(type: "int", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false),
UpdatedAt = table.Column(type: "datetime2", nullable: true),
CreatedBy = table.Column(type: "nvarchar(max)", nullable: true),
UpdatedBy = table.Column(type: "nvarchar(max)", nullable: true),
IsDeleted = table.Column(type: "bit", nullable: false),
DeletedAt = table.Column(type: "datetime2", nullable: true),
DeletedBy = table.Column(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ContactSubmissions", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DashboardTips",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TipText = table.Column(type: "nvarchar(max)", nullable: false),
IsActive = table.Column(type: "bit", nullable: false),
CreatedAt = table.Column(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_DashboardTips", x => x.Id);
});
migrationBuilder.CreateTable(
name: "DataProtectionKeys",
columns: table => new
{
Id = table.Column