
--Migration_RCCP_20240313_142447.txt
CREATE TABLE [dbo].[AccuracyReportLists] (
    [RowID] [int] NOT NULL IDENTITY,
    [ReportID] [bigint] NOT NULL,
    [Serial] [nvarchar](max),
    [CameraID] [int] NOT NULL,
    [CountingType] [int] NOT NULL,
    [PersonTypeID] [int] NOT NULL,
    [TotalAccuracy] [float] NOT NULL,
    [TotalFalseNegative] [int] NOT NULL,
    [TotalFalsePositive] [int] NOT NULL,
    [TotalTrueNegative] [int] NOT NULL,
    [TotalTruePositive] [int] NOT NULL,
    [UploadedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.AccuracyReportLists] PRIMARY KEY ([RowID])
)
CREATE TABLE [dbo].[FFVerificationStudyReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FFCameraId] [bigint] NOT NULL,
    [Summary] [nvarchar](max),
    [CreatedBy] [nvarchar](max),
    [Timestamp] [bigint] NOT NULL,
    [NoOfLog] [int] NOT NULL,
    [ReportType] [int] NOT NULL,
    [ReportDataType] [int] NOT NULL,
    [OverallAccuracyIn] [decimal](18, 2) NOT NULL,
    [OverallAccuracyOut] [decimal](18, 2) NOT NULL,
    [OverallSampleSizeIn] [int] NOT NULL,
    [OverallSampleSizeOut] [int] NOT NULL,
    [CompanyCode] [nvarchar](max),
    [VerifiedBy] [nvarchar](max),
    [SBStatus] [int] NOT NULL,
    [SBKey] [uniqueidentifier] NOT NULL,
    [Filename] [nvarchar](max),
    [ReportSent] [int] NOT NULL,
    [AdditionalComment] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFVerificationStudyReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameras] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [IP] [nvarchar](max),
    [Port] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [SSID] [nvarchar](max),
    [CameraName] [nvarchar](max),
    [Username] [nvarchar](max),
    [Password] [nvarchar](max),
    [CameraFirmwareVersion] [nvarchar](max),
    [CameraStatus] [int] NOT NULL,
    [HTTPS] [bit] NOT NULL,
    [CameraModel] [int] NOT NULL,
    [DSTValue] [int] NOT NULL,
    [DateUpdated] [datetime] NOT NULL,
    [CompanyCode] [nvarchar](max),
    [CounterCameraType] [nvarchar](max),
    [systemCountJson] [nvarchar](max),
    [isCountInAllowUp] [bit] NOT NULL,
    [Serial] [nvarchar](500),
    [CompanySerial] [nvarchar](max),
    [UpdatedDateTime] [datetime] NOT NULL,
    [UserId] [bigint],
    [UserRemarks] [nvarchar](max),
    [Comment] [nvarchar](max),
    [Server] [nvarchar](max),
    [ZoneId] [bigint] NOT NULL,
    [NewZoneId] [bigint],
    [HealthCheckStatus] [int] NOT NULL,
    [LastHeartBeat] [bigint] NOT NULL,
    [ResellerCompanyCode] [nvarchar](max),
    [SiteFloorOrder] [bigint] NOT NULL,
    [SiteFloorPlanName] [nvarchar](max),
    [FloorX] [float] NOT NULL,
    [FloorY] [float] NOT NULL,
    [RotateValue] [float] NOT NULL,
    [ZoomPercentage] [float] NOT NULL,
    [CounterEditedX] [float] NOT NULL,
    [CounterEditedY] [float] NOT NULL,
    [EditingToolX] [float] NOT NULL,
    [EditingToolY] [float] NOT NULL,
    [FloorPlanID] [bigint] NOT NULL,
    [CounterLiveviewURL] [nvarchar](max),
    [ManualZoneID] [nvarchar](max),
    [IsZoneRep] [bit] NOT NULL,
    [Preference] [bit],
    [IssueCategory] [nvarchar](max),
    [CompanyNameReference] [nvarchar](max),
    [BranchNameReference] [nvarchar](max),
    [CameraNameReference] [nvarchar](max),
    [FirmwareUgradedDateTime] [datetime] NOT NULL,
    [FirmwareUpgradedLocalDateTime] [datetime] NOT NULL,
    [PatchUpgradedDateTime] [datetime] NOT NULL,
    [PatchUpgradedLocalDateTime] [datetime] NOT NULL,
    [SameBranchCountersIP] [nvarchar](max),
    [ProgressStatus] [nvarchar](max),
    [Action] [nvarchar](max),
    [Tag] [nvarchar](max),
    [AllocationDateTime] [datetime] NOT NULL,
    [IsStaticIP] [bit] NOT NULL,
    [AllocateStatus] [nvarchar](max),
    [counterPassword] [nvarchar](max),
    [KeyCode] [nvarchar](30),
    [RecentHealthCheckLog] [nvarchar](max),
    [VerifiedBranchCode] [nvarchar](max),
    [syncCounterPassword] [bit] NOT NULL,
    [CustomerLEDLights] [int] NOT NULL,
    [WindowSize] [int] NOT NULL,
    [SMAPEThreshold] [float] NOT NULL,
    [RMSEThreshold] [float] NOT NULL,
    [IsSwingDoor] [bit] NOT NULL,
    [DataPredictionStatus] [nvarchar](max),
    [LastPredictionDateTime] [datetime] NOT NULL,
    [IsRemovedFromSite] [int] NOT NULL,
    [CameraUsageType] [int] NOT NULL,
    [CameraScalingFactor] [float] NOT NULL,
    [CounterWifiScalingFactor] [float] NOT NULL,
    [IsDisabled] [bit] NOT NULL,
    [UsageType] [nvarchar](max),
    [CounterFirstAllocationDateTime] [datetime] NOT NULL,
    [CounterWarrantyExpiryDateTime] [datetime] NOT NULL,
    [notificationStage] [int] NOT NULL,
    [isManualTimeZone] [bit] NOT NULL,
    [isAuthUpdate] [bit] NOT NULL,
    [ShowHeatmapLiveViewScreenshot] [bit] NOT NULL,
    [domainHosts] [nvarchar](max),
    [queueServer] [nvarchar](max),
    [LiveOccupancyServer] [nvarchar](max),
    [CounterServiceVersion] [nvarchar](max),
    [OccupancyThreshold] [int] NOT NULL,
    [OccupancyStartedAt] [datetime] NOT NULL,
    [PatchVersion] [nvarchar](max),
    [isNewWifiVersion] [bit] NOT NULL,
    [DomainHostIP] [nvarchar](max),
    [WifiInsertThreshold] [int] NOT NULL,
    [FilterMac] [bit] NOT NULL,
    [isWifiDisabled] [bit] NOT NULL,
    [EnabledWifiBrowsing] [bit] NOT NULL,
    [isSSIDVisible] [bit] NOT NULL,
    [isWifiModuleDisabled] [bit] NOT NULL,
    [LiveviewPrivacy] [int] NOT NULL,
    [StaffExclusionOffset] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameras] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraCountingValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Counter] [int] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [Day] [int] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraCountingValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraHourlyValues] (
    [ValueDateTime] [datetime] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [OutsideTraffic] [int] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [ValueIn2] [int] NOT NULL,
    [ValueOut2] [int] NOT NULL,
    [ZoneCounting] [int] NOT NULL,
    [HeatMapStay] [int] NOT NULL,
    [HeatMapPassBy] [int] NOT NULL,
    [HeatMapAvgDwell] [float] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    [Day] [int] NOT NULL,
    [PatchStatus] [nvarchar](max),
    [IsAggregated] [int] NOT NULL,
    [PredictedAverage] [int] NOT NULL,
    [IsAlive] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraHourlyValues] PRIMARY KEY ([ValueDateTime], [CameraId])
)
CREATE TABLE [dbo].[CameraLineSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [LineNumber] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [DatasetId] [bigint] NOT NULL,
    [RoiId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.CameraLineSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaConfigurationSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CameraLineId] [bigint] NOT NULL,
    [AreaId] [bigint] NOT NULL,
    [IsInLine] [bit] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AreaConfigurationSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFAreas] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [MinDwellThreshold] [int] NOT NULL,
    [MaxDwellThreshold] [int] NOT NULL,
    [MinDwellExclude] [int] NOT NULL,
    [MaxDwellExclude] [int] NOT NULL,
    [TargetVisitorCount] [int] NOT NULL,
    [AreaGroupTypeId] [uniqueidentifier],
    [AreaCode] [nvarchar](max),
    [Description] [nvarchar](max),
    [Status] [nvarchar](max),
    [ParentAreaId] [bigint],
    [IsDeleted] [bit] NOT NULL,
    [FollowSiteOperatingHour] [bit] NOT NULL,
    [AreaType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFAreas] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AreaAppPermissions] (
    [Id] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [AppPermissionType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.AreaAppPermissions] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFAreaDailies] (
    [Id] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [Date] [datetime] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [NewCustomer] [int] NOT NULL,
    [ReturningCustomer] [int] NOT NULL,
    [LessIntervalWifiCount] [int] NOT NULL,
    [BetweenIntervalWifiCount] [int] NOT NULL,
    [OverIntervalMinWifiCount] [int] NOT NULL,
    [AverageDwellTime] [float] NOT NULL,
    [MinDwellThreshold] [int] NOT NULL,
    [MaxDwellThreshold] [int] NOT NULL,
    [TargetVisitorCount] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFAreaDailies] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFAreaHourlies] (
    [Id] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFAreaHourlies] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BookingSchedules] (
    [ID] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [SiteId] [bigint] NOT NULL,
    [BookingTitle] [nvarchar](max),
    [BookingStartDateTime] [datetime] NOT NULL,
    [BookingStartDateTimeUTC] [datetime] NOT NULL,
    [BookingDuration] [bigint] NOT NULL,
    [BookingTypeEnum] [int] NOT NULL,
    [LocationId] [bigint] NOT NULL,
    [AreaId] [bigint] NOT NULL,
    [IsPushedToEsl] [bit] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [DagRunIds] [nvarchar](max),
    [BookingId] [bigint] NOT NULL,
    [BookingStatus] [int] NOT NULL,
    CONSTRAINT [PK_dbo.BookingSchedules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranches] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [Region] [nvarchar](max),
    [RegionAbbr] [nvarchar](max),
    [City] [nvarchar](max),
    [CityAbbr] [nvarchar](max),
    [Country] [nvarchar](max),
    [CountryAbbr] [nvarchar](max),
    [Timezone] [nvarchar](max),
    [StoreType] [nvarchar](max),
    [Latitude] [float] NOT NULL,
    [Longitude] [float] NOT NULL,
    [FloorSize] [float] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [FTPServer] [nvarchar](max),
    [FTPDirectory] [nvarchar](max),
    [FTPUsername] [nvarchar](max),
    [FTPPassword] [nvarchar](max),
    [Comment] [nvarchar](max),
    [RegionId] [bigint],
    [Offset] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [deleteDate] [datetime] NOT NULL,
    [isLocalTimeServer] [bit] NOT NULL,
    [timeServerAddress] [nvarchar](50),
    [KeyCode] [nvarchar](30),
    [DownloadSpeed] [int] NOT NULL,
    [UploadSpeed] [int] NOT NULL,
    [VideoUploadStartTime] [nvarchar](max),
    [VideoUploadEndTime] [nvarchar](max),
    [DNS1] [varchar](20),
    [DNS2] [varchar](20),
    [isProxy] [bit] NOT NULL,
    [ProxyAddress] [varchar](250),
    [ProxyPort] [int] NOT NULL,
    [ProxyUsername] [varchar](30),
    [ProxyPassword] [varchar](30),
    [Subnet] [varchar](20),
    [Gateway] [varchar](20),
    [MTU] [bigint] NOT NULL,
    [BranchInstallationDatetime] [datetime] NOT NULL,
    [WindowSize] [int] NOT NULL,
    [SMAPEThreshold] [float] NOT NULL,
    [RMSEThreshold] [float] NOT NULL,
    [DataPredictionStatus] [nvarchar](max),
    [LastPredictionDateTime] [datetime] NOT NULL,
    [MinDwellThreshold] [int] NOT NULL,
    [MaxDwellThreshold] [int] NOT NULL,
    [PulsarServerId] [bigint] NOT NULL,
    [NeedPatchWifiData] [bit] NOT NULL,
    [ReturningCustLowerLimit] [int] NOT NULL,
    [ReturningCustUpperLimit] [int] NOT NULL,
    [VisitDurationLowerLimit] [float] NOT NULL,
    [VisitDurationUpperLimit] [float] NOT NULL,
    [StoreImage] [nvarchar](max),
    [DwellTimeSource] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFBranches] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFAreaProfiles] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Date] [datetime] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [Comment] [nvarchar](max),
    [Name] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFAreaProfiles] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFAreaProfileDetails] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CategoryName] [nvarchar](max),
    [AreaProfileId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFAreaProfileDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFAreaSankeys] (
    [Id] [bigint] NOT NULL IDENTITY,
    [FromAreaId] [bigint] NOT NULL,
    [ToAreaId] [bigint] NOT NULL,
    [Date] [datetime] NOT NULL,
    [MacCount] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFAreaSankeys] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFBranchCrossShops] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ToBranch] [bigint] NOT NULL,
    [FromBranch] [bigint] NOT NULL,
    [WifiCount] [int] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchCrossShops] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BranchWorkspaceDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchID] [bigint] NOT NULL,
    [PeriodID] [bigint] NOT NULL,
    [Target] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.BranchWorkspaceDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[WorkspacePeriods] (
    [ID] [bigint] NOT NULL IDENTITY,
    [WorkspaceStartDateTime] [datetime] NOT NULL,
    [WorkspaceEndDateTime] [datetime] NOT NULL,
    [CompanyID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.WorkspacePeriods] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Companies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyCode] [nvarchar](max),
    [CompanyName] [nvarchar](max),
    [NurseryCam] [bit] NOT NULL,
    [RetailCam] [bit] NOT NULL,
    [MagicMirror] [bit] NOT NULL,
    [FootfallCam] [bit] NOT NULL,
    [ConnectionString] [nvarchar](max),
    [ServerName] [nvarchar](max),
    [DatabaseName] [nvarchar](max),
    [DatabaseUsername] [nvarchar](max),
    [DatabasePassword] [nvarchar](max),
    [UpdatedDateTime] [datetime] NOT NULL,
    [UserId] [bigint],
    [ShowOutValue] [bit] NOT NULL,
    [ResellerCompanyCode] [nvarchar](max),
    [ExportCount] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [DeleteDate] [datetime],
    [InstallationPin] [nvarchar](max),
    [ParentCompanyId] [bigint] NOT NULL,
    [ResellerId] [bigint] NOT NULL,
    [OdooPartnerId] [bigint] NOT NULL,
    [IsDeactivated] [bit] NOT NULL,
    [OccupancyControl] [bit] NOT NULL,
    [CompanyLogoUrl] [nvarchar](max),
    [MmcpCompanyId] [uniqueidentifier] NOT NULL,
    [GraviteePlanId] [nvarchar](max),
    [GraviteeAPIKey] [nvarchar](max),
    CONSTRAINT [PK_dbo.Companies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CompanyCards] (
    [CompanyId] [bigint] NOT NULL,
    [CardId] [int] NOT NULL,
    [SortOrder] [int] NOT NULL,
    [RoleAccess] [nvarchar](max),
    CONSTRAINT [PK_dbo.CompanyCards] PRIMARY KEY ([CompanyId])
)
CREATE TABLE [dbo].[FFDataSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Attribute] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [CreatedUserID] [bigint] NOT NULL,
    [EditedDateTime] [datetime] NOT NULL,
    [EditedUserID] [bigint] NOT NULL,
    [DeletedDateTime] [datetime] NOT NULL,
    [DeletedUserID] [bigint] NOT NULL,
    [Type_ID] [bigint],
    [Company_ID] [bigint],
    CONSTRAINT [PK_dbo.FFDataSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[DataSettingTypes] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [ToObjectType] [nvarchar](max),
    CONSTRAINT [PK_dbo.DataSettingTypes] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Locations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CompanyID] [bigint] NOT NULL,
    [SequenceNumber] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [LastUpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.Locations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[LocationAreaLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [LocationId] [bigint] NOT NULL,
    [AreaId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.LocationAreaLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MetricDefinitions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [MetricCode] [nvarchar](max),
    [ThresholdCount] [int] NOT NULL,
    [CompanyID] [bigint] NOT NULL,
    [ThresholdDefinition] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDatetime] [datetime],
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime],
    [ServerGuid] [uniqueidentifier] NOT NULL,
    [IsCreatedOnClientServer] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.MetricDefinitions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MetricThresholdConfigurations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [MetricDefinitionID] [bigint] NOT NULL,
    [IsCreatedOnClientServer] [bit] NOT NULL,
    [ServerGuid] [uniqueidentifier] NOT NULL,
    [Type] [int] NOT NULL,
    [TypeID] [nvarchar](max),
    [ThresholdValue] [float] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime],
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime],
    [isDefault] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.MetricThresholdConfigurations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[PublicHolidayConfigurations] (
    [Id] [bigint] NOT NULL IDENTITY,
    [PublicHolidayName] [nvarchar](max),
    [PublicHolidayDateTime] [datetime] NOT NULL,
    [CreationDateTime] [datetime] NOT NULL,
    [LastUpdatedDateTime] [datetime] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.PublicHolidayConfigurations] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[PublicHolidayLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [PublicHolidayId] [bigint] NOT NULL,
    [GranularityType] [int] NOT NULL,
    [GranularityId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.PublicHolidayLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ScheduledNotifications] (
    [ID] [bigint] NOT NULL IDENTITY,
    [notificationCat] [bigint] NOT NULL,
    [companyID] [bigint] NOT NULL,
    [Status] [smallint] NOT NULL,
    [notificationMode] [smallint] NOT NULL,
    [hoursToSend] [smallint] NOT NULL,
    [lastSendDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.ScheduledNotifications] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[notificationModules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [notificationName] [nvarchar](max),
    [Active] [int] NOT NULL,
    CONSTRAINT [PK_dbo.notificationModules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[scheduledSingleMails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [scheduledEmailID] [bigint] NOT NULL,
    [scheduledNotificationsID] [bigint],
    [email] [nvarchar](max),
    CONSTRAINT [PK_dbo.scheduledSingleMails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ScheduledEmails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReportID] [bigint] NOT NULL,
    [UserGroupID] [bigint] NOT NULL,
    [CompanyCode] [nvarchar](max),
    [BranchID] [bigint] NOT NULL,
    [UserID] [bigint] NOT NULL,
    [SendTime] [datetime] NOT NULL,
    [Date_Changed] [datetime] NOT NULL,
    [Active] [int] NOT NULL,
    [htmlTable] [nvarchar](max),
    [paramJSON] [nvarchar](max),
    CONSTRAINT [PK_dbo.ScheduledEmails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[generateEmailLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [generateStatusDateTime] [datetime] NOT NULL,
    [generateStatus] [smallint] NOT NULL,
    [generateErrorLogs] [nvarchar](max),
    [ScheduledEmailID] [bigint] NOT NULL,
    [GeneratedFile] [nvarchar](max),
    [TimeTaken] [bigint] NOT NULL,
    [EmailQueueId] [bigint],
    CONSTRAINT [PK_dbo.generateEmailLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[sendEmailLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [sendStatusDateTime] [datetime] NOT NULL,
    [sendStatus] [smallint] NOT NULL,
    [sendErrorLogs] [nvarchar](max),
    [ScheduledEmailID] [bigint] NOT NULL,
    [FileToObtain] [nvarchar](max),
    [TimeTaken] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.sendEmailLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[UserGroups] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CompanyID] [bigint] NOT NULL,
    [Date_Changed] [datetime] NOT NULL,
    [Gateway] [int] NOT NULL,
    [RecipientType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.UserGroups] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[userGroupsEmails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserGroupID] [bigint] NOT NULL,
    [Email] [nvarchar](max),
    [RecipientType] [int] NOT NULL,
    [Gateway] [int] NOT NULL,
    [Granularity] [int],
    [DataID] [bigint],
    [UserID] [bigint],
    CONSTRAINT [PK_dbo.userGroupsEmails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Users] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserName] [nvarchar](max) NOT NULL,
    [PasswordHashed] [nvarchar](max) NOT NULL,
    [Salt] [nvarchar](max) NOT NULL,
    [Name] [nvarchar](max) NOT NULL,
    [Email] [nvarchar](max) NOT NULL,
    [CompanyCode] [nvarchar](max),
    [LastLoginTimestamp] [bigint] NOT NULL,
    [UserRole] [nvarchar](max),
    [Language] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [DeleteDate] [datetime],
    [DefaultPage] [nvarchar](max),
    [UserAccessType] [int] NOT NULL,
    [LoginTryCount] [int] NOT NULL,
    [NeedResetPassword] [bit] NOT NULL,
    [PendingVerification] [bit] NOT NULL,
    [IsSubscribeNewsLetters] [bit] NOT NULL,
    [PatchToKCState] [int] NOT NULL,
    [ViewV9Layout] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Users] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[EslCustomFields] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [CustomFieldName] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [LastUpdatedDateTime] [datetime],
    [UserId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.EslCustomFields] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EslCustomFieldTemplateLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [EslCustomFieldId] [bigint] NOT NULL,
    [EslTemplateId] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.EslCustomFieldTemplateLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ESLTemplates] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Name] [nvarchar](max) NOT NULL,
    [TagSize] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [EslModel] [nvarchar](max),
    [ColourDisplay] [int] NOT NULL,
    [TemplateJsonObject] [nvarchar](max),
    [EslDesignToolData] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [LastUpdatedDateTime] [datetime],
    [UserId] [bigint] NOT NULL,
    [UsageType] [int],
    CONSTRAINT [PK_dbo.ESLTemplates] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFUserAccesses] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFUserAccesses] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[UserBookmarkedReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserID] [bigint] NOT NULL,
    [ReportID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.UserBookmarkedReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CustomReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [ReportName] [nvarchar](max),
    [ReportDateRangeStart] [datetime],
    [ReportDateRangeEnd] [datetime],
    [IsAlwaysLatestDateRange] [bit] NOT NULL,
    [ReportFolderID] [bigint],
    [CreatorUserID] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [isPrivate] [bit] NOT NULL,
    [ReportType] [int] NOT NULL,
    [isDeleted] [bit] NOT NULL,
    [ReportDeleteDateTime] [datetime],
    [DeleteUserId] [bigint] NOT NULL,
    [IsTemplate] [bit] NOT NULL,
    [CustomReportGuid] [nvarchar](max),
    [ReportFolderGuid] [nvarchar](max),
    [TemplateType] [int] NOT NULL,
    [Granularity] [int] NOT NULL,
    [TimeInterval] [int] NOT NULL,
    CONSTRAINT [PK_dbo.CustomReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CustomReportAccesses] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [CustomReportId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.CustomReportAccesses] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[ReportFolders] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FolderName] [nvarchar](max),
    [CompanyID] [bigint] NOT NULL,
    [CreatorUserID] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [isPrivate] [bit] NOT NULL,
    [ParentFolderID] [bigint] NOT NULL,
    [isDeleted] [bit] NOT NULL,
    [ReportDeleteDateTime] [datetime],
    [DeleteUserId] [bigint] NOT NULL,
    [isShareToAll] [bit] NOT NULL,
    [ReportFolderGuid] [nvarchar](max),
    CONSTRAINT [PK_dbo.ReportFolders] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CompanySettings] (
    [CompanyId] [bigint] NOT NULL,
    [FTPServer] [nvarchar](max),
    [FTPDirectory] [nvarchar](max),
    [FTPUsername] [nvarchar](max),
    [FTPPassword] [nvarchar](max),
    [ExportVisitor] [bit] NOT NULL,
    [ExportOutsideTraffic] [bit] NOT NULL,
    [ExportTurnInRate] [bit] NOT NULL,
    [ExportDwellTime] [bit] NOT NULL,
    [ExportReturningCustomer] [bit] NOT NULL,
    [ExportCrossShopping] [bit] NOT NULL,
    [DwellTimeCategoriesMin] [int] NOT NULL,
    [DwellTimeCategoriesMax] [int] NOT NULL,
    [SectionSalesConversion] [bit] NOT NULL,
    [SectionStaffPlanning] [bit] NOT NULL,
    [SectionZoneAnalytic] [bit] NOT NULL,
    [FirstDayOfWeek] [nvarchar](max),
    [DateFormat] [nvarchar](max),
    [FinancialWeekDate] [nvarchar](max),
    [ExportVisitorOut] [bit] NOT NULL,
    [WeeklyorDaily] [nvarchar](max),
    [ImportFTPServer] [nvarchar](max),
    [ImportFTPDirectory] [nvarchar](max),
    [ImportFTPUsername] [nvarchar](max),
    [ImportFTPPassword] [nvarchar](max),
    [ImportWeeklyorDaily] [nvarchar](max),
    [AutoScheduler] [bit] NOT NULL,
    [SMTPUse] [bit] NOT NULL,
    [SMTPServer] [nvarchar](max),
    [SMTPPort] [int] NOT NULL,
    [SMTPUseSSL] [int] NOT NULL,
    [SMTPRequiredAuthentication] [bit] NOT NULL,
    [SMTPUsername] [nvarchar](max),
    [SMTPPassword] [nvarchar](max),
    [SMTPFrom] [nvarchar](max),
    [FootfallFTPUsername] [nvarchar](max),
    [FootfallFTPPassword] [nvarchar](max),
    [SQLAccountUsername] [nvarchar](max),
    [SQLAccountPassword] [nvarchar](max),
    [ImportautoScheduler] [bit] NOT NULL,
    [cameraUpdate] [int] NOT NULL,
    [accType] [int] NOT NULL,
    [isRemoteAccess] [bit] NOT NULL,
    [hcHourThreshold] [int] NOT NULL,
    [optOutUpdate] [bit] NOT NULL,
    [betaRelease] [bit] NOT NULL,
    [currency] [nvarchar](max),
    [wifiRadius] [int] NOT NULL,
    [wifithreshold] [int] NOT NULL,
    [shopperthreshold] [int] NOT NULL,
    [OccupancyControl] [int] NOT NULL,
    [WifiScalingFactor] [int] NOT NULL,
    [IsOutsideOHUpgradeFirmware] [bit] NOT NULL,
    [WiFiSsidPassword] [nvarchar](max),
    [DeviceControlPanelPassword] [nvarchar](max),
    [ApplyDefaultPasswordsToAllDevice] [bit] NOT NULL,
    [HideDeviceSSID] [bit] NOT NULL,
    [SEToken] [varbinary](max),
    [IsUsingAD] [bit] NOT NULL,
    [ADId] [nvarchar](max),
    [ADBindCredential] [nvarchar](max),
    [DisabledWifiCounting] [bit] NOT NULL,
    [DisabledWifiModule] [bit] NOT NULL,
    [ViewV9Layout] [bit] NOT NULL,
    [ReportFooter] [nvarchar](max),
    CONSTRAINT [PK_dbo.CompanySettings] PRIMARY KEY ([CompanyId])
)
CREATE TABLE [dbo].[FFCorridors] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFCorridors] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFBranchDailyPredictions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [PredictionDate] [datetime] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchDailyPredictions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFDailyPredictions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Date] [datetime] NOT NULL,
    [LastYearFF] [int] NOT NULL,
    [ThisYearFF] [int] NOT NULL,
    [LastYearTransactionCount] [int] NOT NULL,
    [ThisYearTransactionCount] [int] NOT NULL,
    [PercentageChangeFF] [float] NOT NULL,
    [PercentageChangeTransactionCount] [float] NOT NULL,
    [Weather] [nvarchar](max),
    [BranchDailyPredictionId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFDailyPredictions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFZoneSankeyDailies] (
    [Id] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [ZoneIdA] [bigint] NOT NULL,
    [ZoneIdB] [bigint] NOT NULL,
    [Batch] [int] NOT NULL,
    [WifiCount] [int] NOT NULL,
    [DateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FFZoneSankeyDailies] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFZones] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [Name] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [Floor] [int] NOT NULL,
    [IsEntrance] [bit] NOT NULL,
    [BranchFloorId] [bigint],
    [XAxis] [float] NOT NULL,
    [YAxis] [float] NOT NULL,
    CONSTRAINT [PK_dbo.FFZones] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchFloors] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Abbreviation] [nvarchar](max),
    [LayoutURL] [nvarchar](max),
    [Ratio] [float] NOT NULL,
    [Order] [int] NOT NULL,
    [SiteFloorPlanName] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchFloors] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraZones] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ZoneName] [nvarchar](max),
    [ZoneType] [nvarchar](max),
    [X] [float] NOT NULL,
    [Y] [float] NOT NULL,
    [Radius] [float] NOT NULL,
    [FloorId] [bigint] NOT NULL,
    [ManualZoneID] [nvarchar](max),
    [FFBranchFloor_ID] [bigint],
    CONSTRAINT [PK_dbo.FFCameraZones] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFZoneDailies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ZoneID] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [OutsideTraffic] [int] NOT NULL,
    [AverageDwellTime] [float] NOT NULL,
    [NewCustomer] [int] NOT NULL,
    [ReturningCustomer] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFZoneDailies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFZoneHourlies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ZoneID] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [OutsideTraffic] [int] NOT NULL,
    [ZoneCounting] [int] NOT NULL,
    [HeatMapCounting] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFZoneHourlies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[EslTags] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Serial] [nvarchar](50) NOT NULL,
    [ChipSerial] [nvarchar](max),
    [Price] [float] NOT NULL,
    [Channel] [nvarchar](max),
    [ESLTemplateId] [uniqueidentifier],
    [BranchId] [bigint],
    [ProductId] [uniqueidentifier],
    [ToUpdate] [bit] NOT NULL,
    [BatteryVoltage] [float] NOT NULL,
    [SignalStrength] [float] NOT NULL,
    [LastUpdateDateTime] [datetime],
    [TagFieldsLastUpdateDateTime] [datetime],
    [CreatedDateTime] [datetime],
    [ESLActionLogID] [bigint],
    [CounterSerial] [nvarchar](max),
    [CounterLiveViewCoorX] [float] NOT NULL,
    [CounterLiveViewCoorY] [float] NOT NULL,
    [LastUpdatedDateTimeFromESL] [datetime],
    [ESLStatus] [int] NOT NULL,
    CONSTRAINT [PK_dbo.EslTags] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Products] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [ProductSerial] [nvarchar](100) NOT NULL,
    [ProductBarcode] [nvarchar](2000) NOT NULL,
    [Unit] [nvarchar](max),
    [UnitNumber] [float] NOT NULL,
    [Name] [nvarchar](max),
    [Price] [float] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [ESLActionLogID] [bigint],
    [ProductCategoryId] [uniqueidentifier],
    [Description] [nvarchar](max),
    [ProductBrandId] [bigint],
    [DiscountedPrice] [float] NOT NULL,
    [ProductPromotionHeader] [nvarchar](max),
    [QRCodeLink] [nvarchar](max),
    [LastUpdateDateTime] [datetime],
    [CreatedDateTime] [datetime],
    [ESLMiscJson] [nvarchar](max),
    CONSTRAINT [PK_dbo.Products] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductBrands] (
    [Id] [bigint] NOT NULL IDENTITY,
    [BrandName] [nvarchar](max),
    [ServerDomainPath] [nvarchar](max),
    [LogoPath] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [LastUpdateDateTime] [datetime],
    [NumberOfProducts] [int],
    [CompanyId] [bigint] NOT NULL,
    [ESLActionLogID] [bigint],
    CONSTRAINT [PK_dbo.ProductBrands] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductCategories] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Name] [nvarchar](2000) NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [LastUpdateDateTime] [datetime],
    [CreatedDateTime] [datetime],
    [ESLActionLogID] [bigint],
    CONSTRAINT [PK_dbo.ProductCategories] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductDailySales] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [ProductId] [uniqueidentifier] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [Date] [datetime] NOT NULL,
    [TotalSales] [float] NOT NULL,
    [TotalQuantity] [int] NOT NULL,
    CONSTRAINT [PK_dbo.ProductDailySales] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFBranchOperatingHours] (
    [ID] [bigint] NOT NULL IDENTITY,
    [StartTime] [datetime] NOT NULL,
    [EndTime] [datetime] NOT NULL,
    [Day] [int] NOT NULL,
    [isDayOff] [bit] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [AreaId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchOperatingHours] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFRegions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [Name] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFRegions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SiteGroupLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [SiteGroupId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [CreateDateTime] [datetime] NOT NULL,
    [UpdateDateTime] [datetime],
    [isDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.SiteGroupLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[SiteGroups] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [SiteGroupName] [nvarchar](max),
    [SettingValue] [nvarchar](max),
    [isSpecificSettings] [bit] NOT NULL,
    [CreateDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime],
    [isDeleted] [bit] NOT NULL,
    [isDefault] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.SiteGroups] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFBranchSpecialOperatingHours] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Date] [datetime] NOT NULL,
    [StartTime] [datetime] NOT NULL,
    [EndTime] [datetime] NOT NULL,
    [Comment] [nvarchar](max),
    [isDayOff] [bit] NOT NULL,
    [isRecurrence] [bit] NOT NULL,
    [RecurrenceType] [int] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchSpecialOperatingHours] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SiteVehicleLinks] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [BranchId] [bigint] NOT NULL,
    [Serial] [nvarchar](max),
    CONSTRAINT [PK_dbo.SiteVehicleLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[VirtualReceptionVisitationPurposes] (
    [Id] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [VisitationPurpose] [nvarchar](max),
    [GuestCheckIn] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.VirtualReceptionVisitationPurposes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFCameraOperatingHours] (
    [ID] [bigint] NOT NULL IDENTITY,
    [StartTime] [datetime] NOT NULL,
    [EndTime] [datetime] NOT NULL,
    [Day] [int] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraOperatingHours] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraSettings] (
    [CameraId] [bigint] NOT NULL,
    [Enable] [bit] NOT NULL,
    [InvertIn] [bit] NOT NULL,
    [LineIn] [int] NOT NULL,
    [LineOut] [int] NOT NULL,
    [TopLine1Y] [int] NOT NULL,
    [BottomLine1Y] [int] NOT NULL,
    [IgnoreLeft] [int] NOT NULL,
    [IgnoreRight] [int] NOT NULL,
    [Sensitivity] [int] NOT NULL,
    [ShoulderWidth] [int] NOT NULL,
    [Radius] [int] NOT NULL,
    [MinSize] [int] NOT NULL,
    [Watershed] [bit] NOT NULL,
    [ConvexHull] [bit] NOT NULL,
    [Morph] [nvarchar](max),
    [SecondMorph] [nvarchar](max),
    [Recording] [bit] NOT NULL,
    [RebootFlag] [bit] NOT NULL,
    [RoiX] [float] NOT NULL,
    [RoiY] [float] NOT NULL,
    [RoiW] [float] NOT NULL,
    [RoiH] [float] NOT NULL,
    [AutoUpdate] [bit] NOT NULL,
    [LastUpdatedTimestamp] [bigint] NOT NULL,
    [UpdateSource] [int] NOT NULL,
    [TimeZone] [nvarchar](max),
    [Offset] [nvarchar](max),
    [NtpFlag] [nvarchar](max),
    [NetNtp] [nvarchar](max),
    [LocalNtp] [nvarchar](max),
    [HeartBeat] [bit] NOT NULL,
    [LiveView] [bit] NOT NULL,
    [SoftEther] [bit] NOT NULL,
    [DataAdjustment] [float] NOT NULL,
    [WhiteOptions] [nvarchar](max),
    [ResolutionOption] [nvarchar](max),
    [FPS] [int] NOT NULL,
    [CustomLine] [bit] NOT NULL,
    [InLine] [nvarchar](max),
    [OutLine] [nvarchar](max),
    [EngineeringLog] [bit] NOT NULL,
    [wifithreshold] [int] NOT NULL,
    [shopperthreshold] [int] NOT NULL,
    [wifiRadius] [int] NOT NULL,
    [noiseFilter] [int] NOT NULL,
    [ceilingHeight] [float] NOT NULL,
    [humanMinHeight] [float] NOT NULL,
    [humanMaxHeight] [float] NOT NULL,
    [floorSpace] [nvarchar](max),
    [customFloorSpace] [bit] NOT NULL,
    [StartingZone] [nvarchar](max),
    [Model] [nvarchar](max),
    [Ratio] [nvarchar](max),
    [Mode] [nvarchar](max),
    [PrevZoomX] [nvarchar](max),
    [PrevZoomY] [nvarchar](max),
    [PrevZoomW] [nvarchar](max),
    [PrevZoomH] [nvarchar](max),
    [maxarea] [nvarchar](max),
    [Rotation] [nvarchar](max),
    [Contrast] [nvarchar](max),
    [Brightness] [nvarchar](max),
    [threshold] [nvarchar](max),
    [Gaussian] [nvarchar](max),
    [Morphy] [nvarchar](max),
    [SGBMSADWindow] [nvarchar](max),
    [OffShiftY] [nvarchar](max),
    [OffShiftX] [nvarchar](max),
    [Resolution] [nvarchar](max),
    [RotateLeft] [nvarchar](max),
    [RotateRight] [nvarchar](max),
    [LeftUp] [nvarchar](max),
    [DualScreen] [nvarchar](max),
    [FloorCreation] [nvarchar](max),
    [PersonRecording] [nvarchar](max),
    [BlobRecording] [nvarchar](max),
    [LineCreation] [nvarchar](max),
    [FloorThes] [nvarchar](max),
    [WriteFloor] [nvarchar](max),
    [Zone] [nvarchar](max),
    [iszone] [nvarchar](max),
    [GreenNoise] [nvarchar](max),
    [DebugMode] [nvarchar](max),
    [floorUndefPerc] [nvarchar](max),
    [floorUndefStatus] [nvarchar](max),
    [floorUndefPercRef] [nvarchar](max),
    [floorUndefPercThresh] [nvarchar](max),
    [floorUndefPercThreshMaj] [nvarchar](max),
    [floorUndefCountEnable] [nvarchar](max),
    [floorUndefEnable] [nvarchar](max),
    [doorAvgEnable] [nvarchar](max),
    [doorAvgRef] [nvarchar](max),
    [doorAvgThresh] [nvarchar](max),
    [doorZone] [nvarchar](max),
    [drawFlag] [nvarchar](max),
    [idealSetting] [nvarchar](max),
    [cameraDegree] [nvarchar](max),
    [leftIntrinsic] [nvarchar](max),
    [rightIntrinsic] [nvarchar](max),
    [leftDistortion] [nvarchar](max),
    [rightDistortion] [nvarchar](max),
    [scaledLeftRrect] [nvarchar](max),
    [scaledLeftIntrinsicRect] [nvarchar](max),
    [scaledRightRrect] [nvarchar](max),
    [scaledRightIntrinsicRect] [nvarchar](max),
    [Q] [nvarchar](max),
    [isoui] [int] NOT NULL,
    [xUTurn] [nvarchar](max),
    [autoDetectCeilingHeight] [nvarchar](max),
    [dMapAdvance] [nvarchar](max),
    [Disparity] [nvarchar](max),
    [minDisparity] [nvarchar](max),
    [uniquenessRatio] [nvarchar](max),
    [preFilterCap] [nvarchar](max),
    [speckleWindowSize] [nvarchar](max),
    [speckleRange] [nvarchar](max),
    [disp12MaxDiff] [nvarchar](max),
    [textureThreshold] [nvarchar](max),
    [DepthMapRecording] [bit] NOT NULL,
    [RecordingType] [int] NOT NULL,
    [isSettingAdjusted] [bit] NOT NULL,
    [SettingAdjustedTime] [datetime] NOT NULL,
    [preFilterSize] [nvarchar](max),
    [PinkPatchSaveFramePeriodMinute] [nvarchar](max),
    [pathMaxFrame] [nvarchar](max),
    [startEndMode] [nvarchar](max),
    [PinkPatchDecayRate] [nvarchar](max),
    [PinkPatchStep] [nvarchar](max),
    [speed] [nvarchar](max),
    [createdLog] [nvarchar](max),
    [recordingError] [nvarchar](max),
    [setnewCeilingheight] [nvarchar](max),
    [setnewTimezone] [nvarchar](max),
    [LegacyTracking] [nvarchar](max),
    [LegacySpeed] [nvarchar](max),
    [PinkPatchGrowthRate] [nvarchar](max),
    [PinkPatchDrawLive] [nvarchar](max),
    [RecordPlusDepth] [nvarchar](max),
    [GreenNoiseThresh] [nvarchar](max),
    [GreenNoiseGrowthRate] [nvarchar](max),
    [GreenNoiseMaintainRate] [nvarchar](max),
    [RecordPlusDepthCurrent] [nvarchar](max),
    [CameraResetPeriod] [nvarchar](max),
    [PinkPatchMode] [nvarchar](max),
    [PinkPatch2dUpperTrigger] [nvarchar](max),
    [PinkPatch2dLowerTrigger] [nvarchar](max),
    [PinkPatch2dGrowthRate] [nvarchar](max),
    [PinkPatch2dDecayRate] [nvarchar](max),
    [cameraDegreeDisplay] [nvarchar](max),
    [TurboMode] [nvarchar](max),
    [queueCounting] [nvarchar](max),
    [frameCounted] [nvarchar](max),
    [drawBeamFlag] [nvarchar](max),
    [BeamZone1] [nvarchar](max),
    [BeamZone2] [nvarchar](max),
    [BeamZonePosition] [nvarchar](max),
    [deltaBeamOneThreshold] [nvarchar](max),
    [deltaBeamTwoThreshold] [nvarchar](max),
    [percentageBeamOnePixelThreshold] [nvarchar](max),
    [percentageBeamTwoPixelThreshold] [nvarchar](max),
    [countListSizeLimit] [nvarchar](max),
    [outListSizeLimit] [nvarchar](max),
    [brightnessBeamFlag] [nvarchar](max),
    [deltaDequeBeamOne] [nvarchar](max),
    [deltaDequeBeamTwo] [nvarchar](max),
    [positionBeamFlag] [nvarchar](max),
    [exclusionLineCounting] [nvarchar](max),
    [exclusionLine] [nvarchar](max),
    [exclusionCancelMode] [nvarchar](max),
    [ShoulderWidth3D] [nvarchar](max),
    [BlobMinSize] [nvarchar](max),
    [SGBMMode] [nvarchar](max),
    [frameCount] [nvarchar](max),
    [OccupancyStart] [bit] NOT NULL,
    [TelegramStart] [bit] NOT NULL,
    [ScadaRemoteStart] [bit] NOT NULL,
    [QueueCountingStart] [bit] NOT NULL,
    [SmartBinStart] [bit] NOT NULL,
    [WashRoomButtonStart] [bit] NOT NULL,
    [isRevise] [bit] NOT NULL,
    [ToggleWebServerState] [int] NOT NULL,
    [UpgradeManagerStart] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraSettings] PRIMARY KEY ([CameraId])
)
CREATE TABLE [dbo].[FFCameraSettingBackUps] (
    [CameraId] [bigint] NOT NULL,
    [Enable] [bit] NOT NULL,
    [InvertIn] [bit] NOT NULL,
    [LineIn] [int] NOT NULL,
    [LineOut] [int] NOT NULL,
    [TopLine1Y] [int] NOT NULL,
    [BottomLine1Y] [int] NOT NULL,
    [IgnoreLeft] [int] NOT NULL,
    [IgnoreRight] [int] NOT NULL,
    [Sensitivity] [int] NOT NULL,
    [ShoulderWidth] [int] NOT NULL,
    [Radius] [int] NOT NULL,
    [MinSize] [int] NOT NULL,
    [Watershed] [bit] NOT NULL,
    [ConvexHull] [bit] NOT NULL,
    [Morph] [nvarchar](max),
    [SecondMorph] [nvarchar](max),
    [Recording] [bit] NOT NULL,
    [RebootFlag] [bit] NOT NULL,
    [RoiX] [float] NOT NULL,
    [RoiY] [float] NOT NULL,
    [RoiW] [float] NOT NULL,
    [RoiH] [float] NOT NULL,
    [AutoUpdate] [bit] NOT NULL,
    [LastUpdatedTimestamp] [bigint] NOT NULL,
    [UpdateSource] [int] NOT NULL,
    [TimeZone] [nvarchar](max),
    [Offset] [nvarchar](max),
    [NtpFlag] [nvarchar](max),
    [NetNtp] [nvarchar](max),
    [LocalNtp] [nvarchar](max),
    [HeartBeat] [bit] NOT NULL,
    [LiveView] [bit] NOT NULL,
    [SoftEther] [bit] NOT NULL,
    [DataAdjustment] [float] NOT NULL,
    [WhiteOptions] [nvarchar](max),
    [ResolutionOption] [nvarchar](max),
    [FPS] [int] NOT NULL,
    [CustomLine] [bit] NOT NULL,
    [InLine] [nvarchar](max),
    [OutLine] [nvarchar](max),
    [EngineeringLog] [bit] NOT NULL,
    [wifithreshold] [int] NOT NULL,
    [shopperthreshold] [int] NOT NULL,
    [noiseFilter] [int] NOT NULL,
    [ceilingHeight] [float] NOT NULL,
    [humanMinHeight] [float] NOT NULL,
    [humanMaxHeight] [float] NOT NULL,
    [floorSpace] [nvarchar](max),
    [customFloorSpace] [bit] NOT NULL,
    [StartingZone] [nvarchar](max),
    [Model] [nvarchar](max),
    [Ratio] [nvarchar](max),
    [Mode] [nvarchar](max),
    [PrevZoomX] [nvarchar](max),
    [PrevZoomY] [nvarchar](max),
    [PrevZoomW] [nvarchar](max),
    [PrevZoomH] [nvarchar](max),
    [maxarea] [nvarchar](max),
    [Rotation] [nvarchar](max),
    [Contrast] [nvarchar](max),
    [Brightness] [nvarchar](max),
    [threshold] [nvarchar](max),
    [Gaussian] [nvarchar](max),
    [Morphy] [nvarchar](max),
    [SGBMSADWindow] [nvarchar](max),
    [OffShiftY] [nvarchar](max),
    [OffShiftX] [nvarchar](max),
    [Resolution] [nvarchar](max),
    [RotateLeft] [nvarchar](max),
    [RotateRight] [nvarchar](max),
    [LeftUp] [nvarchar](max),
    [DualScreen] [nvarchar](max),
    [FloorCreation] [nvarchar](max),
    [PersonRecording] [nvarchar](max),
    [BlobRecording] [nvarchar](max),
    [LineCreation] [nvarchar](max),
    [FloorThes] [nvarchar](max),
    [WriteFloor] [nvarchar](max),
    [Zone] [nvarchar](max),
    [iszone] [nvarchar](max),
    [GreenNoise] [nvarchar](max),
    [DebugMode] [nvarchar](max),
    [floorUndefPerc] [nvarchar](max),
    [floorUndefStatus] [nvarchar](max),
    [floorUndefPercRef] [nvarchar](max),
    [floorUndefPercThresh] [nvarchar](max),
    [floorUndefPercThreshMaj] [nvarchar](max),
    [floorUndefCountEnable] [nvarchar](max),
    [floorUndefEnable] [nvarchar](max),
    [doorAvgEnable] [nvarchar](max),
    [doorAvgRef] [nvarchar](max),
    [doorAvgThresh] [nvarchar](max),
    [doorZone] [nvarchar](max),
    [drawFlag] [nvarchar](max),
    [idealSetting] [nvarchar](max),
    [cameraDegree] [nvarchar](max),
    [leftIntrinsic] [nvarchar](max),
    [rightIntrinsic] [nvarchar](max),
    [leftDistortion] [nvarchar](max),
    [rightDistortion] [nvarchar](max),
    [scaledLeftRrect] [nvarchar](max),
    [scaledLeftIntrinsicRect] [nvarchar](max),
    [scaledRightRrect] [nvarchar](max),
    [scaledRightIntrinsicRect] [nvarchar](max),
    [Q] [nvarchar](max),
    [isoui] [int] NOT NULL,
    [xUTurn] [nvarchar](max),
    [autoDetectCeilingHeight] [nvarchar](max),
    [dMapAdvance] [nvarchar](max),
    [Disparity] [nvarchar](max),
    [minDisparity] [nvarchar](max),
    [uniquenessRatio] [nvarchar](max),
    [preFilterCap] [nvarchar](max),
    [speckleWindowSize] [nvarchar](max),
    [speckleRange] [nvarchar](max),
    [disp12MaxDiff] [nvarchar](max),
    [textureThreshold] [nvarchar](max),
    [DepthMapRecording] [bit] NOT NULL,
    [RecordingType] [int] NOT NULL,
    [isSettingAdjusted] [bit] NOT NULL,
    [SettingAdjustedTime] [datetime] NOT NULL,
    [preFilterSize] [nvarchar](max),
    [PinkPatchSaveFramePeriodMinute] [nvarchar](max),
    [pathMaxFrame] [nvarchar](max),
    [startEndMode] [nvarchar](max),
    [PinkPatchDecayRate] [nvarchar](max),
    [PinkPatchStep] [nvarchar](max),
    [speed] [nvarchar](max),
    [createdLog] [nvarchar](max),
    [recordingError] [nvarchar](max),
    [setnewCeilingheight] [nvarchar](max),
    [setnewTimezone] [nvarchar](max),
    [LegacyTracking] [nvarchar](max),
    [LegacySpeed] [nvarchar](max),
    [PinkPatchGrowthRate] [nvarchar](max),
    [PinkPatchDrawLive] [nvarchar](max),
    [RecordPlusDepth] [nvarchar](max),
    [GreenNoiseThresh] [nvarchar](max),
    [GreenNoiseGrowthRate] [nvarchar](max),
    [GreenNoiseMaintainRate] [nvarchar](max),
    [RecordPlusDepthCurrent] [nvarchar](max),
    [CameraResetPeriod] [nvarchar](max),
    [PinkPatchMode] [nvarchar](max),
    [PinkPatch2dUpperTrigger] [nvarchar](max),
    [PinkPatch2dLowerTrigger] [nvarchar](max),
    [PinkPatch2dGrowthRate] [nvarchar](max),
    [PinkPatch2dDecayRate] [nvarchar](max),
    [cameraDegreeDisplay] [nvarchar](max),
    [TurboMode] [nvarchar](max),
    [queueCounting] [nvarchar](max),
    [frameCounted] [nvarchar](max),
    [drawBeamFlag] [nvarchar](max),
    [BeamZone1] [nvarchar](max),
    [BeamZone2] [nvarchar](max),
    [BeamZonePosition] [nvarchar](max),
    [deltaBeamOneThreshold] [nvarchar](max),
    [deltaBeamTwoThreshold] [nvarchar](max),
    [percentageBeamOnePixelThreshold] [nvarchar](max),
    [percentageBeamTwoPixelThreshold] [nvarchar](max),
    [countListSizeLimit] [nvarchar](max),
    [outListSizeLimit] [nvarchar](max),
    [brightnessBeamFlag] [nvarchar](max),
    [deltaDequeBeamOne] [nvarchar](max),
    [deltaDequeBeamTwo] [nvarchar](max),
    [positionBeamFlag] [nvarchar](max),
    [exclusionLineCounting] [nvarchar](max),
    [exclusionLine] [nvarchar](max),
    [exclusionCancelMode] [nvarchar](max),
    [ShoulderWidth3D] [nvarchar](max),
    [BlobMinSize] [nvarchar](max),
    [SGBMMode] [nvarchar](max),
    [frameCount] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFCameraSettingBackUps] PRIMARY KEY ([CameraId])
)
CREATE TABLE [dbo].[FFCameraSimulatorSettings] (
    [CameraId] [bigint] NOT NULL,
    [InvertIn] [bit] NOT NULL,
    [LineIn] [int] NOT NULL,
    [LineOut] [int] NOT NULL,
    [TopLine1Y] [int] NOT NULL,
    [BottomLine1Y] [int] NOT NULL,
    [IgnoreLeft] [int] NOT NULL,
    [IgnoreRight] [int] NOT NULL,
    [Sensitivity] [int] NOT NULL,
    [ShoulderWidth] [int] NOT NULL,
    [Radius] [int] NOT NULL,
    [MinSize] [int] NOT NULL,
    [Watershed] [bit] NOT NULL,
    [ConvexHull] [bit] NOT NULL,
    [Morph] [nvarchar](max),
    [SecondMorph] [nvarchar](max),
    [WhiteOptions] [nvarchar](max),
    [Recording] [bit] NOT NULL,
    [RoiX] [float] NOT NULL,
    [RoiY] [float] NOT NULL,
    [RoiW] [float] NOT NULL,
    [RoiH] [float] NOT NULL,
    [InLine] [nvarchar](max),
    [OutLine] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFCameraSimulatorSettings] PRIMARY KEY ([CameraId])
)
CREATE TABLE [dbo].[NotificationTriggers] (
    [Id] [bigint] NOT NULL IDENTITY,
    [SubjectOutput] [nvarchar](max),
    [Output] [nvarchar](max),
    [Threshold] [int] NOT NULL,
    [Name] [nvarchar](max),
    [IsActive] [bit] NOT NULL,
    [Type] [nvarchar](max),
    [CompanyId] [bigint],
    [Level] [int],
    [LevelId] [bigint],
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [NotificationSettingsId] [bigint],
    CONSTRAINT [PK_dbo.NotificationTriggers] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[NotificationSettings] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Value] [nvarchar](max),
    CONSTRAINT [PK_dbo.NotificationSettings] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFVerificationStudyReportVideos] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FFVideoScheduleId] [bigint] NOT NULL,
    [FFVerificationStudyReportId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFVerificationStudyReportVideos] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFVideoSchedules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FFCameraId] [bigint] NOT NULL,
    [ScheduleDateTime] [datetime] NOT NULL,
    [Duration] [int] NOT NULL,
    [SessionKey] [uniqueidentifier] NOT NULL,
    [FileName] [nvarchar](max),
    [Timestamp] [bigint] NOT NULL,
    [Progress] [int] NOT NULL,
    [Status] [int] NOT NULL,
    [VerificationStudyTimestamp] [bigint] NOT NULL,
    [SystemCountIn] [int] NOT NULL,
    [SystemCountOut] [int] NOT NULL,
    [ManualCountIn] [int] NOT NULL,
    [ManualCountOut] [int] NOT NULL,
    [AccuracyIn] [decimal](18, 2) NOT NULL,
    [AccuracyOut] [decimal](18, 2) NOT NULL,
    [VerifyBy] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [OverallComment] [nvarchar](max),
    [SBStatus] [int] NOT NULL,
    [RecordingType] [int] NOT NULL,
    [RowCreatedDateTime] [datetime] NOT NULL,
    [DifferenceIn] [int] NOT NULL,
    [DifferenceOut] [int] NOT NULL,
    [VideoScheduleRetrivalStatus] [int] NOT NULL,
    [VideoScheduleRetrievalDateTime] [datetime] NOT NULL,
    [FirmwareBuildNumber] [int] NOT NULL,
    [Annotated] [bit] NOT NULL,
    [PatchVersion] [nvarchar](max),
    [HumanSampleCount] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFVideoSchedules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[VideoSchedules] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [VideoScheduleId] [bigint] NOT NULL,
    [Accuracy] [float] NOT NULL,
    [CameraId] [int] NOT NULL,
    [PersonTypeId] [int] NOT NULL,
    [Counting_type] [int] NOT NULL,
    [FalseNegative] [int] NOT NULL,
    [FalsePositive] [int] NOT NULL,
    [TrueNegative] [int] NOT NULL,
    [TruePositive] [int] NOT NULL,
    CONSTRAINT [PK_dbo.VideoSchedules] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[VideoScheduleDatas] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [VideoScheduleId] [bigint] NOT NULL,
    [FrameNumber] [bigint] NOT NULL,
    [PredictedResult] [nvarchar](max),
    [TriggerType] [nvarchar](max),
    CONSTRAINT [PK_dbo.VideoScheduleDatas] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[ActualStaffSchedules] (
    [Id] [bigint] NOT NULL IDENTITY,
    [StaffId] [bigint] NOT NULL,
    [StartDateTime] [datetime] NOT NULL,
    [EndDateTime] [datetime] NOT NULL,
    [Type] [int],
    [Day] [int],
    [IsOffDay] [bit],
    [CompanyId] [bigint] NOT NULL,
    [SiteId] [bigint] NOT NULL,
    [TotalWage] [float] NOT NULL,
    CONSTRAINT [PK_dbo.ActualStaffSchedules] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AlertRules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Type] [int] NOT NULL,
    [Event] [int] NOT NULL,
    [TimeToTrigger] [int] NOT NULL,
    [RealertTime] [int] NOT NULL,
    [CompanyID] [bigint] NOT NULL,
    [IsActive] [bit] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [AlertType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.AlertRules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[NotificationAlerts] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [RuleId] [bigint] NOT NULL,
    [MessageTemplateId] [uniqueidentifier],
    [Gateway] [int] NOT NULL,
    [OutputAction] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.NotificationAlerts] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MessageTemplates] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [TemplateName] [nvarchar](max),
    [TemplateType] [int] NOT NULL,
    [TemplateContent] [nvarchar](max),
    [EmailSubject] [nvarchar](max),
    [EmailOutpostServerId] [uniqueidentifier] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.MessageTemplates] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[NotificationRecipients] (
    [ID] [bigint] NOT NULL IDENTITY,
    [NotificationId] [bigint] NOT NULL,
    [UserGroupId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.NotificationRecipients] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[RuleTriggerConditions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [RuleID] [bigint] NOT NULL,
    [Event] [int] NOT NULL,
    [Detail] [nvarchar](max),
    CONSTRAINT [PK_dbo.RuleTriggerConditions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[RuleActions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [RuleTriggerConditionID] [bigint] NOT NULL,
    [Gateway] [int] NOT NULL,
    [Detail] [nvarchar](max),
    [RuleId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.RuleActions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ThresholdMetricRules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [MetricCode] [nvarchar](max),
    [Granularity] [int] NOT NULL,
    [MonitorCondition] [int] NOT NULL,
    [TargetThreshold] [nvarchar](max),
    [AlertRuleId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ThresholdMetricRules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AllCounterAllocationHistories] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CounterAllocationHistoryId] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [CompanyName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [BranchName] [nvarchar](max),
    [BranchCode] [nvarchar](max),
    [CounterSerial] [nvarchar](max),
    [CounterCompanySerial] [nvarchar](max),
    [AllocationType] [int] NOT NULL,
    [OccuredDateTime] [datetime] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [IsMeta] [bit] NOT NULL,
    [AllocationSource] [int] NOT NULL,
    [IsPatch] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AllCounterAllocationHistories] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AllServerAreas] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [ParentAreaId] [bigint] NOT NULL,
    [ServerGUID] [nvarchar](max),
    [MinDwellThreshold] [int] NOT NULL,
    [MaxDwellThreshold] [int] NOT NULL,
    [MinDwellExclude] [int] NOT NULL,
    [MaxDwellExclude] [int] NOT NULL,
    [TargetVisitorCount] [int] NOT NULL,
    [FollowSiteOperatingHour] [bit] NOT NULL,
    [OperatingHour] [nvarchar](max),
    [AreaName] [nvarchar](max),
    [UpdatedDateTime] [datetime] NOT NULL,
    [AreaType] [int] NOT NULL,
    [AreaCode] [nvarchar](max),
    CONSTRAINT [PK_dbo.AllServerAreas] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AllServerBranches] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [ServerAddress] [nvarchar](max),
    [ServerName] [nvarchar](max),
    [BranchID] [bigint] NOT NULL,
    [BranchName] [nvarchar](max),
    [BranchCode] [nvarchar](max),
    [OperatingHour] [nvarchar](max),
    [Region] [nvarchar](max),
    [Country] [nvarchar](max),
    [CountryAbbr] [nvarchar](max),
    [Timezone] [nvarchar](max),
    [Offset] [nvarchar](max),
    [Latitude] [float] NOT NULL,
    [Longitude] [float] NOT NULL,
    [IsStaticIP] [bit] NOT NULL,
    [IsITSettingConfigured] [bit] NOT NULL,
    [KeyCode] [nvarchar](max),
    [ServerGUID] [nvarchar](max),
    [EstimatedCounters] [int] NOT NULL,
    [InstalledCounterSerial] [nvarchar](max),
    [InstalledCounterCount] [int] NOT NULL,
    [ITSettingIP] [nvarchar](max),
    [InstalledCounterIP] [nvarchar](max),
    [InstalledCounterExternalIP] [nvarchar](max),
    [VideoUploadStartTime] [nvarchar](max),
    [VideoUploadEndTime] [nvarchar](max),
    [CompanyID] [bigint] NOT NULL,
    [TrialStatus] [int] NOT NULL,
    [DownloadSpeed] [int] NOT NULL,
    [UploadSpeed] [int] NOT NULL,
    [MinDwellThreshold] [int] NOT NULL,
    [MaxDwellThreshold] [int] NOT NULL,
    [OfflineDeviceCount] [int] NOT NULL,
    [LowStorageDevicesCount] [int] NOT NULL,
    [LowMemoryDevicesCount] [int] NOT NULL,
    [FrequentRebootDevicesCount] [int] NOT NULL,
    [HighTemperatureDevicesCount] [int] NOT NULL,
    [CameraIsNotDetectedDevicesCount] [int] NOT NULL,
    [RaspicamNotRunningDevicesCount] [int] NOT NULL,
    [DeviceTunedPercentage] [float] NOT NULL,
    [DeviceTunedCount] [int] NOT NULL,
    [DeviceTotalCount] [int] NOT NULL,
    [InOutDataAggregation] [int] NOT NULL,
    [WifiDataAggregation] [int] NOT NULL,
    [InOutDiscrepancy] [float] NOT NULL,
    [StepChangeCount] [int] NOT NULL,
    [SpaceOccupancyFoldCount] [int] NOT NULL,
    [SpikeCount] [int] NOT NULL,
    [LowTraffic] [int] NOT NULL,
    [OpenRMATicket] [bit] NOT NULL,
    [OpenSupportTicket] [bit] NOT NULL,
    [SiteIsVerified] [bit] NOT NULL,
    [SiteVerifiedDate] [datetime] NOT NULL,
    [SiteProfileKeys] [nvarchar](max),
    [CountingUsage] [nvarchar](max),
    [SiteGroupIds] [nvarchar](max),
    [SiteFinancialEntityId] [bigint] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [OccupancyQualityScore] [float] NOT NULL,
    [CountingAggregationStatus] [int] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerBranches] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AllServerCompanies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ServerGUID] [nvarchar](max),
    [CompanyID] [bigint] NOT NULL,
    [CompanyName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [InstallationPin] [nvarchar](max),
    [SageReferenceId] [nvarchar](max),
    [OdooPartnerId] [bigint] NOT NULL,
    [IsTrialCustomer] [bit] NOT NULL,
    [ParentCompanyId] [bigint] NOT NULL,
    [ResellerId] [bigint] NOT NULL,
    [IsDeactivated] [bit] NOT NULL,
    [ModifiedIsDeactivated] [bit] NOT NULL,
    [IsDeactivatedFromV9] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerCompanies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AllServerConfigurationUserGroups] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ConfigurationUserGroupId] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [UserGroupName] [nvarchar](max),
    [Hierarchy] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [DeletedDateTime] [datetime],
    [UpdatedDateTime] [datetime],
    CONSTRAINT [PK_dbo.AllServerConfigurationUserGroups] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AllServerExceptionLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ServerGUID] [uniqueidentifier] NOT NULL,
    [Method] [nvarchar](max),
    [ExceptionType] [nvarchar](max),
    [OccuredDateTime] [datetime] NOT NULL,
    [LastOccuredDateTime] [datetime] NOT NULL,
    [ErrorCount] [int] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerExceptionLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AllServerFFUserAccesses] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGUID] [nvarchar](max),
    [UserId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerFFUserAccesses] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AllServerSiteGroups] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [SiteGroupId] [bigint] NOT NULL,
    [SiteGroupName] [nvarchar](max),
    [SettingValue] [nvarchar](max),
    [IsSpecificSettings] [bit] NOT NULL,
    [IsDeletedByCompany] [bit] NOT NULL,
    [IsDefault] [bit] NOT NULL,
    [BranchID] [bigint] NOT NULL,
    [IsDeletedByBranch] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerSiteGroups] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AllServerUsers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ServerGUID] [nvarchar](max),
    [CompanyID] [bigint] NOT NULL,
    [UserName] [nvarchar](max),
    [UserID] [bigint] NOT NULL,
    [Name] [nvarchar](max),
    [Email] [nvarchar](max),
    [UserRole] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [DeleteDate] [datetime],
    [IsSubscribeNewsLetters] [bit] NOT NULL,
    [PasswordHashed] [nvarchar](max),
    [Salt] [nvarchar](max),
    [ServerShortId] [nvarchar](max),
    [UserAccessType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerUsers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AllServerUserGroupLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [UserId] [bigint] NOT NULL,
    [ConfigurationUserGroupId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerUserGroupLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AllServerUserGroupSettings] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ConfigurationUserGroupId] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    [UserActionId] [int] NOT NULL,
    [CreateAccess] [bit] NOT NULL,
    [ReadAccess] [bit] NOT NULL,
    [UpdateAccess] [bit] NOT NULL,
    [DeleteAccess] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerUserGroupSettings] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AllServerUserSiteGroupLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGUID] [nvarchar](max),
    [UserId] [bigint] NOT NULL,
    [SiteGroupId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.AllServerUserSiteGroupLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AnnouncementMessages] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [Message] [nvarchar](max),
    [NotifyDateTime] [datetime],
    [ExpiryDateTime] [datetime],
    CONSTRAINT [PK_dbo.AnnouncementMessages] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ApiActions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FFVideoScheduleId] [bigint],
    [isRead] [bit] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ApiActions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AppInstances] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [AppType] [int] NOT NULL,
    [Name] [nvarchar](max),
    [Logo] [nvarchar](max),
    [Url] [nvarchar](max),
    [AppTemplateId] [bigint] NOT NULL,
    [Version] [nvarchar](max),
    [Permission] [nvarchar](max),
    [MariaDBPort] [nvarchar](max),
    [YAMLFileLocation] [nvarchar](max),
    [CreatedUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.AppInstances] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AppTemplates] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [AppType] [int] NOT NULL,
    [Logo] [nvarchar](max),
    [Version] [nvarchar](max),
    [Permission] [nvarchar](max),
    [YAMLFileLocation] [nvarchar](max),
    [CreatedUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.AppTemplates] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaCameraLinks] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.AreaCameraLinks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaDatasets] (
    [Id] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [MetricId] [bigint] NOT NULL,
    [MetricDetails] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.AreaDatasets] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AreaGroupingConfigurations] (
    [Id] [uniqueidentifier] NOT NULL,
    [ParentAreaId] [bigint] NOT NULL,
    [ChildAreaId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.AreaGroupingConfigurations] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AreaGroupTypes] (
    [Id] [uniqueidentifier] NOT NULL,
    [Name] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [SystemCreatedAreaGroup] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AreaGroupTypes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[AreaPlots] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FloorPlanPolygonID] [nvarchar](max),
    [PolygonName] [nvarchar](max),
    [Color] [nvarchar](max),
    [FloorplanID] [bigint] NOT NULL,
    [FloorplanGuid] [uniqueidentifier] NOT NULL,
    [AreaID] [bigint] NOT NULL,
    [PlotType] [int] NOT NULL,
    [RotateDegree] [float] NOT NULL,
    CONSTRAINT [PK_dbo.AreaPlots] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SiteFloorplanDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FloorplanGuid] [uniqueidentifier] NOT NULL,
    [FloorplanName] [nvarchar](max),
    [FloorplanSourcePath] [nvarchar](max),
    [BranchID] [bigint] NOT NULL,
    [ActualDistance] [bigint] NOT NULL,
    [FloorplanScaleValue] [bigint] NOT NULL,
    [FloorplanData] [nvarchar](max),
    [CurrentDeviceID] [nvarchar](max),
    [CanvasBaseWidth] [bigint] NOT NULL,
    [ServerGUID] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [LastUpdatedDateTime] [datetime],
    [UserId] [bigint] NOT NULL,
    [EntityTypeId] [bigint] NOT NULL,
    [EntityType] [int] NOT NULL,
    [ExistenceType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.SiteFloorplanDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[DevicePlots] (
    [ID] [bigint] NOT NULL IDENTITY,
    [DeviceName] [nvarchar](max),
    [CameraLensType] [int] NOT NULL,
    [MountingHeight] [float] NOT NULL,
    [DeviceUsage] [int] NOT NULL,
    [FloorplanID] [bigint] NOT NULL,
    [DeviceID] [nvarchar](max),
    [DeviceSerial] [nvarchar](max),
    [RotateDegree] [float] NOT NULL,
    [FloorplanGuid] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.DevicePlots] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaSpaceAmenities] (
    [ID] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [AreaId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [Amenity] [nvarchar](max),
    CONSTRAINT [PK_dbo.AreaSpaceAmenities] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaSpaceConfigurations] (
    [ID] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [AreaId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [Capacity] [bigint] NOT NULL,
    [BookingTimeGranularity] [int] NOT NULL,
    [SpaceDescription] [nvarchar](max),
    [IncludeInWorkspaceAutomationApp] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.AreaSpaceConfigurations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaSpaceImages] (
    [ID] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [AreaId] [bigint] NOT NULL,
    [ImagePath] [nvarchar](max),
    CONSTRAINT [PK_dbo.AreaSpaceImages] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaStaffHours] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [StaffCount] [bigint] NOT NULL,
    [RowCreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.AreaStaffHours] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaTransactionDatas] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [TransactionCount] [bigint] NOT NULL,
    [UnitSold] [bigint] NOT NULL,
    [SalesAmount] [float] NOT NULL,
    [AverageAmount] [float] NOT NULL,
    [RowCreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.AreaTransactionDatas] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AreaUsageSessions] (
    [SessionId] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [SessionStartDateTime] [datetime],
    [SessionEndDateTime] [datetime],
    [SessionDuration] [int] NOT NULL,
    CONSTRAINT [PK_dbo.AreaUsageSessions] PRIMARY KEY ([SessionId])
)
CREATE TABLE [dbo].[AreaUsageSessionsSummaries] (
    [MeetingId] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [SessionId] [bigint],
    [BookingId] [bigint],
    [MeetingStartDateTime] [datetime],
    [MeetingEndDateTime] [datetime],
    [MeetingDuration] [int] NOT NULL,
    [MeetingStatus] [nvarchar](max),
    [MeetingAvgOccupancy] [float] NOT NULL,
    CONSTRAINT [PK_dbo.AreaUsageSessionsSummaries] PRIMARY KEY ([MeetingId])
)
CREATE TABLE [dbo].[AutoExportFileCustomisations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AutoExportSettingID] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [isCustomise] [bit] NOT NULL,
    [isCustomiseFileName] [bit] NOT NULL,
    [customiseFileName] [nvarchar](max),
    [isCustomiseFileColumn] [bit] NOT NULL,
    [customiseFileColumn] [nvarchar](max),
    [delimeter] [nvarchar](max),
    CONSTRAINT [PK_dbo.AutoExportFileCustomisations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AutoExportLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [dataType] [nvarchar](max),
    [frequency] [int] NOT NULL,
    [ExportedDateTime] [datetime] NOT NULL,
    [status] [int] NOT NULL,
    [ExportLogs] [nvarchar](max),
    [ExportLogsLocation] [nvarchar](max),
    [AutoExportId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.AutoExportLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AutoExportSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [FTPUserName] [nvarchar](max),
    [FTPPassword] [nvarchar](max),
    [FTPHost] [nvarchar](max),
    [FTPPort] [int] NOT NULL,
    [FTPDirectory] [nvarchar](max),
    [DataLevel] [nvarchar](max),
    [LevelID] [nvarchar](max),
    [Period] [int] NOT NULL,
    [DataType] [nvarchar](max),
    [DateFormat] [nvarchar](max),
    [TimeFormat] [nvarchar](max),
    [Frequency] [int] NOT NULL,
    [LastExportStatus] [int] NOT NULL,
    [LastExport] [datetime] NOT NULL,
    [ExportType] [int] NOT NULL,
    [userGroupID] [bigint] NOT NULL,
    [SendTime] [datetime] NOT NULL,
    [exportDay] [nvarchar](max),
    [exportFormatType] [nvarchar](max),
    [Email] [nvarchar](max),
    [encryptionMode] [nvarchar](max),
    [dataConnectionType] [nvarchar](max),
    [toggleFtp] [bit] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [isSftp] [nvarchar](max),
    [sftpUsername] [nvarchar](max),
    [sftpPassword] [nvarchar](max),
    [sftpDirectory] [nvarchar](max),
    [sftpPort] [int],
    [sftpServer] [nvarchar](max),
    [ppkFilePath] [nvarchar](max),
    [ppkFilePassword] [nvarchar](max),
    CONSTRAINT [PK_dbo.AutoExportSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AutoImportLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [dataType] [nvarchar](max),
    [frequency] [nvarchar](max),
    [ImportedDateTime] [datetime] NOT NULL,
    [status] [nvarchar](max),
    [ImportLogs] [nvarchar](max),
    [ImportLogsLocation] [nvarchar](max),
    CONSTRAINT [PK_dbo.AutoImportLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[AutoImportSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [FTPUserName] [nvarchar](max),
    [FTPPassword] [nvarchar](max),
    [FTPHost] [nvarchar](max),
    [FTPPort] [int] NOT NULL,
    [FTPDirectory] [nvarchar](max),
    [dataType] [nvarchar](max),
    [frequency] [nvarchar](max),
    [branchCodeIndex] [int] NOT NULL,
    [branchCode] [nvarchar](max),
    [dateTimeIndex] [int] NOT NULL,
    [dateTime] [nvarchar](max),
    [dateTimeFormat] [nvarchar](max),
    [totalTransQtyIndex] [int] NOT NULL,
    [totalTransQty] [nvarchar](max),
    [totalTransValueIndex] [int] NOT NULL,
    [totalTransValue] [nvarchar](max),
    [fileName] [nvarchar](max),
    [ImportedDateTime] [datetime] NOT NULL,
    [status] [nvarchar](max),
    [ImportDateTime] [datetime] NOT NULL,
    [ImportDay] [nvarchar](max),
    [Email] [nvarchar](max),
    [encryptionMode] [nvarchar](max),
    [dataConnectionType] [nvarchar](max),
    [salesFileFormatType] [nvarchar](max),
    [saleTimeIndex] [nvarchar](max),
    [isSftp] [nvarchar](max),
    [sftpUsername] [nvarchar](max),
    [sftpPassword] [nvarchar](max),
    [sftpDirectory] [nvarchar](max),
    [sftpPort] [int],
    [sftpServer] [nvarchar](max),
    [ppkFilePath] [nvarchar](max),
    [ppkFilePassword] [nvarchar](max),
    CONSTRAINT [PK_dbo.AutoImportSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[BandwidthMonitorings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [LocalDateTime] [datetime] NOT NULL,
    [Rx_Eth0] [int] NOT NULL,
    [Tx_Eth0] [int] NOT NULL,
    [Rx_Wlan0] [int] NOT NULL,
    [Tx_Wlan0] [int] NOT NULL,
    [Rx_Vpn] [int] NOT NULL,
    [Tx_Vpn] [int] NOT NULL,
    [Serial] [nvarchar](max),
    [Timestamp] [bigint] NOT NULL,
    [Status] [int] NOT NULL,
    CONSTRAINT [PK_dbo.BandwidthMonitorings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[BetaCubeCredentials] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Username] [nvarchar](max),
    [Password] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.BetaCubeCredentials] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Bus_BusTripLink] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Serial] [nvarchar](max),
    [BusTripId] [uniqueidentifier] NOT NULL,
    [Date] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.Bus_BusTripLink] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BusTrips] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [TripName] [nvarchar](max),
    [TripCode] [nvarchar](max),
    [BusRouteId] [uniqueidentifier] NOT NULL,
    [OperateOnSunday] [bit] NOT NULL,
    [OperateOnMonday] [bit] NOT NULL,
    [OperateOnTuesday] [bit] NOT NULL,
    [OperateOnWednesday] [bit] NOT NULL,
    [OperateOnThursday] [bit] NOT NULL,
    [OperateOnFriday] [bit] NOT NULL,
    [OperateOnSaturday] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.BusTrips] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BusRoutes] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [RouteName] [nvarchar](max),
    [RouteCode] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.BusRoutes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BusTicketSalesDatas] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [TicketSoldDateTime] [datetime] NOT NULL,
    [BusRouteId] [uniqueidentifier] NOT NULL,
    [BusTripId] [uniqueidentifier] NOT NULL,
    [BusStationId] [uniqueidentifier] NOT NULL,
    [BusDetailId] [uniqueidentifier] NOT NULL,
    [Date] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.BusTicketSalesDatas] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BusDetails] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [VehicleRegistration] [nvarchar](max),
    [Serial] [nvarchar](max),
    CONSTRAINT [PK_dbo.BusDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BusStations] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [BusStationName] [nvarchar](max),
    [StationCode] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [Latitude] [float] NOT NULL,
    [Longitude] [float] NOT NULL,
    CONSTRAINT [PK_dbo.BusStations] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[BusTripStationLinks] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [ScheduledStartTime] [datetime] NOT NULL,
    [ScheduledEndTime] [datetime] NOT NULL,
    [BusTripId] [uniqueidentifier] NOT NULL,
    [BusStationId] [uniqueidentifier] NOT NULL,
    [Date] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.BusTripStationLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Certs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CreatedDate] [datetime] NOT NULL,
    [UpdatedDate] [datetime] NOT NULL,
    [CSR] [nvarchar](max),
    [PrivateKey] [nvarchar](max),
    [Certificate] [nvarchar](max),
    [CaCertificate] [nvarchar](max),
    CONSTRAINT [PK_dbo.Certs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CleaningTaskDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [RuleId] [bigint] NOT NULL,
    [AreaId] [bigint] NOT NULL,
    [TaskAcceptedUtcDateTime] [datetime],
    [CleanedUtcDateTime] [datetime],
    [LastAlertUtcDateTime] [datetime],
    [CompletionUtcDateTime] [datetime],
    [TaskAge] [int] NOT NULL,
    CONSTRAINT [PK_dbo.CleaningTaskDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CommissionVersions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Version] [nvarchar](max),
    [FileLocation] [nvarchar](max),
    [FileName] [nvarchar](max),
    [ReleaseDate] [datetime] NOT NULL,
    [Active] [bit] NOT NULL,
    [Description] [nvarchar](max),
    [BuiltNumber] [int] NOT NULL,
    CONSTRAINT [PK_dbo.CommissionVersions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CompanyBusPostProcesses] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [NeedPostProcess] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.CompanyBusPostProcesses] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanyBusPostProcessLogs] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [TriggerDateTime] [datetime] NOT NULL,
    [ProcessedDate] [datetime] NOT NULL,
    [FileUrl] [nvarchar](max),
    [Status] [bigint] NOT NULL,
    [Message] [nvarchar](max),
    CONSTRAINT [PK_dbo.CompanyBusPostProcessLogs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanyCounterSettings] (
    [CompanyId] [bigint] NOT NULL,
    [isFTP] [bit] NOT NULL,
    [host] [nvarchar](max),
    [directory] [nvarchar](max),
    [username] [nvarchar](max),
    [password] [nvarchar](max),
    [isCrontab] [bit] NOT NULL,
    [crontabValue] [nvarchar](max),
    [isFileName] [bit] NOT NULL,
    [fileName] [nvarchar](max),
    [fileFormat] [nvarchar](max),
    [isDataFormat] [bit] NOT NULL,
    [delimiters] [nvarchar](max),
    [dataserializeoutput] [nvarchar](max),
    [fileNameDateFormat] [nvarchar](max),
    [fileNameTimeFormat] [nvarchar](max),
    [dataNameDateFormat] [nvarchar](max),
    [dataType] [nvarchar](max),
    [chipsetCodeType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.CompanyCounterSettings] PRIMARY KEY ([CompanyId])
)
CREATE TABLE [dbo].[CompanyCreationRequests] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [CompanyName] [nvarchar](max),
    [UserName] [nvarchar](max),
    [UserDisplayName] [nvarchar](max),
    [UserEmailAddress] [nvarchar](max),
    [IsCreated] [bit] NOT NULL,
    [CreateDateTime] [datetime],
    [OdooPartnerId] [bigint] NOT NULL,
    [ResellerId] [bigint] NOT NULL,
    [IsOdooPartnerIdUpdated] [bit] NOT NULL,
    [IsDetailsConfirmed] [bit] NOT NULL,
    [Message] [nvarchar](max),
    [IsSageAccountCreated] [bit] NOT NULL,
    [CustomerDetails] [nvarchar](max),
    [ShouldResendActivationEmail] [bit] NOT NULL,
    [IsResellerAccount] [bit] NOT NULL,
    [AccountManagerId] [bigint] NOT NULL,
    [SalesOrderId] [nvarchar](max),
    [SageReferenceId] [nvarchar](max),
    [LastUpdateDateTime] [datetime],
    [IsFinancialEntityCreated] [bit] NOT NULL,
    [CompanyCurrency] [nvarchar](max),
    [SupportContractTypeId] [bigint] NOT NULL,
    [SupportContractMonthlyRate] [decimal](18, 2) NOT NULL,
    [RequestFinancialEntityName] [nvarchar](max),
    [ProductType] [int] NOT NULL,
    [RequestType] [int] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.CompanyCreationRequests] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanyEmailOutpostServers] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [CompanyId] [bigint] NOT NULL,
    [ServerName] [nvarchar](max),
    [SenderName] [nvarchar](max),
    [SmtpServer] [nvarchar](max),
    [SmtpPort] [bigint] NOT NULL,
    [SmtpAuthentication] [bit] NOT NULL,
    [SmtpUsername] [nvarchar](max),
    [SmtpPassword] [nvarchar](max),
    [SmtpUseSsl] [bit] NOT NULL,
    [SmtpSslType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.CompanyEmailOutpostServers] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanyEntityLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [EntityType] [nvarchar](max),
    [EntityTypeId] [nvarchar](max),
    CONSTRAINT [PK_dbo.CompanyEntityLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanyPageLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [PageId] [nvarchar](max),
    CONSTRAINT [PK_dbo.CompanyPageLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanyPaymentAccounts] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [Currency] [nvarchar](max),
    [CurrencyBalance] [decimal](18, 2) NOT NULL,
    [FinancialEntityId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.CompanyPaymentAccounts] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanyPaymentTransactions] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [FinancialEntityId] [bigint] NOT NULL,
    [TransactionUtcDateTime] [datetime],
    [Amount] [decimal](18, 2) NOT NULL,
    [TransactionNumber] [nvarchar](max),
    [Status] [bigint] NOT NULL,
    [SageType] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.CompanyPaymentTransactions] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CompanySupportContractSubscriptions] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [PlanId] [bigint] NOT NULL,
    [StartedUtcDateTime] [datetime] NOT NULL,
    [EndedUtcDateTime] [datetime],
    CONSTRAINT [PK_dbo.CompanySupportContractSubscriptions] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Components] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Type] [nvarchar](max),
    [Variant] [nvarchar](max),
    [BoardVersion] [nvarchar](max),
    [ChipsetCode] [nvarchar](max),
    [BatchID] [nvarchar](max),
    [A_Value] [nvarchar](max),
    [B_Value] [nvarchar](max),
    [X_Value] [int] NOT NULL,
    [Y_Value] [int] NOT NULL,
    [NoLoad] [real] NOT NULL,
    [Loaded] [real] NOT NULL,
    [MilliVolt] [real] NOT NULL,
    [status] [nvarchar](max),
    [UniqueID] [nvarchar](max),
    [FirmwareVersion] [nvarchar](max),
    [RSSI_Value] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.Components] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CounterAllocationHistories] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [CompanyName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [BranchName] [nvarchar](max),
    [BranchCode] [nvarchar](max),
    [CounterSerial] [nvarchar](max),
    [CounterCompanySerial] [nvarchar](max),
    [AllocationType] [int] NOT NULL,
    [OccuredDateTime] [datetime] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [IsMeta] [bit] NOT NULL,
    [AllocationSource] [int] NOT NULL,
    CONSTRAINT [PK_dbo.CounterAllocationHistories] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CounterEnvironmentConstraints] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Serial] [nvarchar](max),
    [ConstraintValue] [bigint] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.CounterEnvironmentConstraints] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CounterEnvironmentConstraintOptions] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ConstraintStringValue] [nvarchar](max),
    [UpdatedDateTime] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.CounterEnvironmentConstraintOptions] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CounterExceptionLogs] (
    [Id] [uniqueidentifier] NOT NULL,
    [CameraSerial] [nvarchar](max),
    [ExceptionMessage] [nvarchar](max),
    [ExceptionScript] [nvarchar](max),
    [DateTime] [datetime] NOT NULL,
    [IsFixed] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.CounterExceptionLogs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CounterFirmwarePatchLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Serial] [nvarchar](max),
    [UpdatedFirmwareVersionOrPatchVersion] [nvarchar](max),
    [CounterDateTime] [datetime] NOT NULL,
    [CounterLocalDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.CounterFirmwarePatchLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CounterHealthChecks] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ServerGUID] [nvarchar](max),
    [ResellerCompanyCode] [nvarchar](max),
    [FfCameraId] [bigint] NOT NULL,
    [CompanyCode] [nvarchar](max),
    [CompanyName] [nvarchar](max),
    [CompanyID] [bigint] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [SiteOperatingHourStartTime] [nvarchar](max),
    [SiteOperatingHourEndTime] [nvarchar](max),
    [SiteCountersCount] [int] NOT NULL,
    [SiteVerifiedDateTime] [datetime] NOT NULL,
    [IsSiteVerified] [bit] NOT NULL,
    [BranchInstallationDatetime] [datetime] NOT NULL,
    [BranchID] [bigint] NOT NULL,
    [Serial] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [CameraName] [nvarchar](max),
    [CounterTimeZoneOffset] [nvarchar](max),
    [IP] [nvarchar](max),
    [Port] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [HTTPS] [bit] NOT NULL,
    [CameraFirmwareVersion] [nvarchar](max),
    [CounterCameraType] [nvarchar](max),
    [Server] [nvarchar](max),
    [IsSiteOperatingHourSet] [bit] NOT NULL,
    [IsVerified] [bit] NOT NULL,
    [CounterVerifiedDateTime] [datetime] NOT NULL,
    [CounterFirstVerifiedDatetime] [datetime] NOT NULL,
    [CeilingHeight] [float] NOT NULL,
    [Reverify] [nvarchar](max),
    [Urgent] [nvarchar](max),
    [HasRecording] [bit] NOT NULL,
    [AllocationDateTime] [datetime] NOT NULL,
    [LastUpdatedDateTime] [datetime] NOT NULL,
    [CurrentAllocationStatus] [int] NOT NULL,
    [PatchVersion] [nvarchar](100),
    [LastHeartBeat] [bigint] NOT NULL,
    [LastHeartBeatDateTime] [datetime] NOT NULL,
    [UTCLastHeartBeatDateTime] [datetime] NOT NULL,
    [LastOnlineDay] [float] NOT NULL,
    [IsOnline] [bit] NOT NULL,
    [LastOnlineMinutes] [float] NOT NULL,
    [CounterDateTime] [datetime] NOT NULL,
    [InOutDiscrepancyCount] [int] NOT NULL,
    [BigInOutDiscrepancyCount] [int] NOT NULL,
    [SmallInOutDiscrepancyCount] [int] NOT NULL,
    [CounterBigInOutDiscrepancyCount] [int] NOT NULL,
    [CounterSmallInOutDiscrepancyCount] [int] NOT NULL,
    [MissingHeartBeatCount] [int] NOT NULL,
    [MissingHourlyDataCount] [int] NOT NULL,
    [MissingWiFiHourlyDataCount] [int] NOT NULL,
    [NullHourlyDataCount] [int] NOT NULL,
    [RaspicamNotRunningCount] [int] NOT NULL,
    [WifiNotRunningCount] [int] NOT NULL,
    [RebootCount] [int] NOT NULL,
    [SafeModeCount] [int] NOT NULL,
    [Minute0] [int] NOT NULL,
    [Minute1] [int] NOT NULL,
    [Minute2] [int] NOT NULL,
    [Minute3] [int] NOT NULL,
    [Minute4] [int] NOT NULL,
    [Minute5] [int] NOT NULL,
    [CounterHasStepChange] [bit] NOT NULL,
    [CountOfWeekWithStepChange_Counter] [int] NOT NULL,
    [AverageOfStepChangeMagnitude_Counter] [float] NOT NULL,
    [SiteHasStepChange] [bit] NOT NULL,
    [CountOfWeekWithStepChange_Site] [int] NOT NULL,
    [AverageOfStepChangeMagnitude_Site] [float] NOT NULL,
    [Verification_Try] [nvarchar](max),
    [Verification_Status] [nvarchar](max),
    [Verification_UserRemark] [nvarchar](max),
    [Verification_Tuner] [nvarchar](max),
    [Verification_TunerOdooUserId] [bigint] NOT NULL,
    [Verification_Reviewer] [nvarchar](max),
    [Verification_StartDateTime] [datetime] NOT NULL,
    [Verification_EndDateTime] [datetime] NOT NULL,
    [OverallAccuracyIn] [decimal](18, 2) NOT NULL,
    [OverallAccuracyOut] [decimal](18, 2) NOT NULL,
    [OverallSampleSizeIn] [int] NOT NULL,
    [OverallSampleSizeOut] [int] NOT NULL,
    [ReverifyCharge] [bit] NOT NULL,
    [IsUserRequestVerification] [bit] NOT NULL,
    [AuditStage] [int] NOT NULL,
    [AuditSpecialStatus] [int] NOT NULL,
    [FollowUpDateTime] [datetime] NOT NULL,
    [Priority] [int] NOT NULL,
    [NotesForCustomer] [nvarchar](max),
    [InternalNote] [nvarchar](max),
    [ReverifyDateTime] [datetime] NOT NULL,
    [OfflineSimVideoScheduleCount] [int] NOT NULL,
    [ParamLastUpdatedTimestamp] [bigint] NOT NULL,
    [ReverifyStartTimestamp] [bigint] NOT NULL,
    [HasOfflineSimSchedule] [bit] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [TransactionCount] [int] NOT NULL,
    [SalesConversion] [float] NOT NULL,
    [AnomalyScore] [float] NOT NULL,
    [StepChangeAnomalyScore] [float] NOT NULL,
    [SiteStepChangeAnomalyScore] [float] NOT NULL,
    [CounterLED] [int] NOT NULL,
    [HCuserRemark] [nvarchar](max),
    [HCAction] [int] NOT NULL,
    [CustomerDataIssueCategory] [nvarchar](max),
    [CustomerDataIssueComment] [nvarchar](max),
    [Verification_ProblemStatement] [nvarchar](max),
    [CustomerDataIssueCommentTimestamp] [bigint] NOT NULL,
    [FFCDataIssueCategory] [nvarchar](max),
    [FFCDataIssueComment] [nvarchar](max),
    [FFCDataIssueCommentTimestamp] [bigint] NOT NULL,
    [CounterParamStatus] [nvarchar](max),
    [ReportSendStatus] [nvarchar](max),
    [FTPExportStatus] [nvarchar](max),
    [SalesConversionAggregationStatus] [nvarchar](max),
    [IsBranchAggregated] [int] NOT NULL,
    [FailedVideoUploadCount] [int] NOT NULL,
    [AutomatedCounterLEDReply] [nvarchar](max),
    [SiteLastAggregation] [nvarchar](max),
    [ResellerID] [nvarchar](max),
    [floorSpaceCount] [int] NOT NULL,
    [humanDetectCount] [int] NOT NULL,
    [objectCount] [int] NOT NULL,
    [DBCount] [nvarchar](max),
    [CounterStorageSize] [bigint] NOT NULL,
    [CounterMemorySize] [bigint] NOT NULL,
    [CameraNotDetected] [bit] NOT NULL,
    [RaspicamNotRunning] [bit] NOT NULL,
    [Temperature] [float] NOT NULL,
    [CounterLocalDateTime] [datetime] NOT NULL,
    [ProactiveSupportLine] [int] NOT NULL,
    [ProactiveSupportPersonName] [nvarchar](max),
    [ProactiveSupportReason] [nvarchar](max),
    [ProactiveInternalNote] [nvarchar](max),
    [ProactiveLineUpdateDateTime] [datetime] NOT NULL,
    [RMAStage] [int] NOT NULL,
    [RMAExternalRemark] [nvarchar](max),
    [IsCounterDisabled] [bit] NOT NULL,
    [UsageType] [nvarchar](max),
    [ReverificationFrequency] [int] NOT NULL,
    [ResellerFootfallCamRemark] [nvarchar](max),
    [CounterValueIn] [int] NOT NULL,
    [CounterValueOut] [int] NOT NULL,
    [CounterFirstAllocationDateTime] [datetime] NOT NULL,
    [CounterWarrantyExpiryDateTime] [datetime] NOT NULL,
    [IssueTrackerFollowUpStatus] [nvarchar](max),
    [IssueTrackerFollowUpDate] [datetime] NOT NULL,
    [DisableClientServerCounterCounting] [int] NOT NULL,
    [DownloadSpeed] [bigint] NOT NULL,
    [UploadSpeed] [bigint] NOT NULL,
    [SpeedUpdatedUTCDateTime] [datetime] NOT NULL,
    [RMAOpen] [bit] NOT NULL,
    [RMARequestStatus] [int] NOT NULL,
    [CounterServiceVersion] [nvarchar](max),
    [counterCurrentHostsIP] [nvarchar](max),
    [AccuracyTuningRequestUpdateDateTime] [datetime],
    [ProductCode] [nvarchar](max),
    [ProductDisplayName] [nvarchar](max),
    [DeviceAccuracyAuditStageUpdateDateTime] [datetime],
    [DeviceWarrantyDurationYear] [int] NOT NULL,
    [TotalWarrantyDuration] [int] NOT NULL,
    [Dns1] [nvarchar](max),
    [Dns2] [nvarchar](max),
    [Mtu] [nvarchar](max),
    [ReverificationReason] [bigint] NOT NULL,
    [ReverificationSource] [bigint] NOT NULL,
    [DeviceLiveviewLastUpdatedDateTime] [datetime],
    [IsSSIDVisible] [bit] NOT NULL,
    [IsStaticIP] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.CounterHealthChecks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CounterLiveviewPorts] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Mode] [nvarchar](max),
    [Port] [bigint] NOT NULL,
    [ServerAddress] [nvarchar](max),
    [Status] [int] NOT NULL,
    [StartedDateTime] [datetime] NOT NULL,
    [Serial] [nvarchar](max),
    CONSTRAINT [PK_dbo.CounterLiveviewPorts] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CounterParamArchives] (
    [RowId] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [UploadedDateTime] [datetime] NOT NULL,
    [CounterSerial] [nvarchar](max),
    [VerificationFilesPath] [nvarchar](max),
    [VerificationRemark] [nvarchar](max),
    [CounterServiceVersion] [nvarchar](max),
    [GeoLocation] [nvarchar](max),
    CONSTRAINT [PK_dbo.CounterParamArchives] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[CounterUsageConfigurations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CounterSerial] [nvarchar](max),
    [UsageType] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [ServerGuid] [nvarchar](max),
    CONSTRAINT [PK_dbo.CounterUsageConfigurations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Countries] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CountryName] [nvarchar](max),
    [CountryShortCode] [nvarchar](max),
    CONSTRAINT [PK_dbo.Countries] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CountryPrices] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CountryId] [nvarchar](max),
    [CountryName] [nvarchar](max),
    [EndUserPrice] [nvarchar](max),
    [ResellerPrice] [nvarchar](max),
    [DisplayPrice] [nvarchar](max),
    [CountryCurrency] [nvarchar](max),
    [AllowRequestCallBack] [bit] NOT NULL,
    [CallBackCondition] [nvarchar](max),
    CONSTRAINT [PK_dbo.CountryPrices] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Credits] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Type] [int] NOT NULL,
    [EntityType] [int] NOT NULL,
    [EntityTypeId] [nvarchar](max),
    [CreatedUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.Credits] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CreditConsumptions] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CreditId] [bigint] NOT NULL,
    [EntityType] [int] NOT NULL,
    [EntityTypeId] [nvarchar](max),
    [UtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.CreditConsumptions] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CustomDashboardWidgets] (
    [ID] [bigint] NOT NULL IDENTITY,
    [WidgetName] [nvarchar](max),
    [WidgetFunctionName] [nvarchar](max),
    [WidgetWidth] [bigint] NOT NULL,
    [WidgetHeight] [bigint] NOT NULL,
    [WidgetX] [bigint] NOT NULL,
    [WidgetY] [bigint] NOT NULL,
    [UserID] [bigint] NOT NULL,
    [WidgetCSSClasses] [nvarchar](max),
    [WidgetHTMLTag] [nvarchar](max),
    [WidgetPagePlacement] [bigint] NOT NULL,
    [WidgetController] [nvarchar](max),
    [ReportId] [bigint],
    [WidgetDateRangeStart] [datetime],
    [WidgetDateRangeEnd] [datetime],
    [IsCustomMetricWidget] [bit] NOT NULL,
    [CustomMetric1FunctionName] [nvarchar](max),
    [CustomMetric2FunctionName] [nvarchar](max),
    [CustomMetricGoalFunctionName] [nvarchar](max),
    [CustomMetricGoalValue] [int] NOT NULL,
    [DataSettingsLevel] [int] NOT NULL,
    [OverrideDataID] [nvarchar](max),
    [OverrideDataIDType] [int] NOT NULL,
    [WidgetContent] [nvarchar](max),
    [WidgetId] [nvarchar](max),
    [isDeleted] [bit] NOT NULL,
    [WidgetDeleteDateTime] [datetime],
    [DeleteUserId] [bigint] NOT NULL,
    [PlywoodPayload] [nvarchar](max),
    [TurniloPreviewContent] [nvarchar](max),
    [CustomReportGuid] [nvarchar](max),
    CONSTRAINT [PK_dbo.CustomDashboardWidgets] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[CustomReportIndustries] (
    [Id] [bigint] NOT NULL IDENTITY,
    [customReportId] [bigint] NOT NULL,
    [industryId] [bigint] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.CustomReportIndustries] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[CustomServerDataProviders] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyID] [bigint] NOT NULL,
    [ConnectionString] [nvarchar](max),
    CONSTRAINT [PK_dbo.CustomServerDataProviders] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[DashboardFolderLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [FolderId] [bigint] NOT NULL,
    [DashboardInstanceId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.DashboardFolderLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DashboardInstances] (
    [Id] [bigint] NOT NULL IDENTITY,
    [TemplateId] [bigint] NOT NULL,
    [Dashboard] [nvarchar](max),
    [Caption] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [DashboardGuid] [nvarchar](max),
    [Template] [bit] NOT NULL,
    [StorageType] [nvarchar](max),
    [ServerGuid] [nvarchar](max),
    [Version] [nvarchar](max),
    [IsPublish] [bit] NOT NULL,
    [ReportType] [bigint] NOT NULL,
    [IsEdited] [bit] NOT NULL,
    [SupportPortal] [bit] NOT NULL,
    [Parameters] [nvarchar](max),
    [Configurations] [nvarchar](max),
    CONSTRAINT [PK_dbo.DashboardInstances] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DashboardReportInstanceUserLinks] (
    [ID] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [DashboardInstanceId] [bigint] NOT NULL,
    [UserID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.DashboardReportInstanceUserLinks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[DashboardReportStorages] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Dashboard] [nvarchar](max),
    [Caption] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [DashboardGuid] [nvarchar](max),
    [Template] [bit] NOT NULL,
    [StorageType] [nvarchar](max),
    [ServerGuid] [nvarchar](max),
    [IsPublish] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.DashboardReportStorages] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DashboardTemplates] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Dashboard] [nvarchar](max),
    [Caption] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [DashboardGuid] [nvarchar](max),
    [Template] [bit] NOT NULL,
    [StorageType] [nvarchar](max),
    [ServerGuid] [nvarchar](max),
    [Version] [nvarchar](max),
    [IsPublish] [bit] NOT NULL,
    [ReportType] [bigint] NOT NULL,
    [IsEdited] [bit] NOT NULL,
    [Parameters] [nvarchar](max),
    [Configurations] [nvarchar](max),
    CONSTRAINT [PK_dbo.DashboardTemplates] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DatabaseUsages] (
    [Id] [int] NOT NULL IDENTITY,
    [TableName] [nvarchar](max),
    [Reserved] [float] NOT NULL,
    [Used] [float] NOT NULL,
    [Diff] [float] NOT NULL,
    [DateString] [nvarchar](max),
    CONSTRAINT [PK_dbo.DatabaseUsages] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DataGridFilterPanelFavourites] (
    [Id] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [DataGridEnum] [int] NOT NULL,
    [IsDefault] [bit] NOT NULL,
    [Name] [nvarchar](max),
    [Value] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [ShareWithAllUser] [bit] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [IsSystemCreated] [bit] NOT NULL,
    [UserType] [int] NOT NULL,
    [ColumnOrdering] [nvarchar](max),
    CONSTRAINT [PK_dbo.DataGridFilterPanelFavourites] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DataPatchLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [startDate] [datetime] NOT NULL,
    [endDate] [datetime] NOT NULL,
    [modifiedDate] [datetime] NOT NULL,
    [patchSelection] [nvarchar](max),
    [patchLevel] [nvarchar](max),
    [patchPeriod] [nvarchar](max),
    [metrics] [nvarchar](max),
    [username] [nvarchar](max),
    [companyCode] [nvarchar](max),
    [patchLevelIDs] [bigint] NOT NULL,
    [PatchStatus] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.DataPatchLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Datasets] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Code] [nvarchar](max),
    [Name] [nvarchar](max),
    [Version] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Datasets] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DatasetComparisonPeriodLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DatasetId] [bigint] NOT NULL,
    [ComparisonPeriodId] [bigint] NOT NULL,
    [IsDefault] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.DatasetComparisonPeriodLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DatasetCurrentPeriodLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DatasetId] [bigint] NOT NULL,
    [CurrentPeriodId] [bigint] NOT NULL,
    [IsDefault] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.DatasetCurrentPeriodLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DatasetEnums] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Type] [nvarchar](max),
    [Code] [nvarchar](max),
    [Name] [nvarchar](max),
    CONSTRAINT [PK_dbo.DatasetEnums] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DatasetGranularityEntityLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DatasetId] [bigint] NOT NULL,
    [GranularityEntityId] [bigint] NOT NULL,
    [IsDefault] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.DatasetGranularityEntityLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DatasetMetricLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DatasetId] [bigint] NOT NULL,
    [MetricId] [bigint] NOT NULL,
    [IsDefault] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.DatasetMetricLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DatasetTimeResolutionLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DatasetId] [bigint] NOT NULL,
    [TimeResolutionId] [bigint] NOT NULL,
    [IsDefault] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.DatasetTimeResolutionLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DataSyncs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [DataType] [nvarchar](max),
    [Value] [nvarchar](max),
    [EntryDateTime] [datetime] NOT NULL,
    [ServerGuid] [nvarchar](max),
    [isSync] [bit] NOT NULL,
    [ReferenceKey] [nvarchar](max),
    [ActionFrom] [nvarchar](max),
    [UpdatedDateTime] [datetime],
    CONSTRAINT [PK_dbo.DataSyncs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[DateCommentDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserCommentId] [bigint] NOT NULL,
    [StartUtcDateTime] [datetime] NOT NULL,
    [EndUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.DateCommentDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[DatabaseJobLogs] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompletedDateTime] [datetime] NOT NULL,
    [ServerGuid] [nvarchar](max),
    [JobName] [nvarchar](max),
    [IsSuccessful] [bit] NOT NULL,
    [Message] [nvarchar](max),
    [TimeTaken] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.DatabaseJobLogs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DevexpressDashboardReportQueries] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DataConnectionStringName] [nvarchar](max),
    [DataProcessingMode] [nvarchar](max),
    [DatasourceName] [nvarchar](max),
    [QueryName] [nvarchar](max),
    [QueryData] [nvarchar](max),
    [Publish] [bit] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.DevexpressDashboardReportQueries] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DeviceBandwidths] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Serial] [nvarchar](max),
    [DownloadSpeed] [float] NOT NULL,
    [UploadSpeed] [float] NOT NULL,
    [StartDateTime] [datetime] NOT NULL,
    [EndDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.DeviceBandwidths] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DeviceConfigurationJobs] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Serial] [nvarchar](max),
    [ConfigKey] [nvarchar](max),
    [ConfigValue] [nvarchar](max),
    [LatestStatus] [int] NOT NULL,
    [LastUpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.DeviceConfigurationJobs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DeviceConfigurations] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Serial] [nvarchar](max),
    [LatestStatus] [bit] NOT NULL,
    [ConfigKey] [nvarchar](max),
    [PreviousConfigValue] [nvarchar](max),
    [CurrentConfigValue] [nvarchar](max),
    [LastUpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.DeviceConfigurations] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DevicePathmapStatus] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DeviceSerial] [nvarchar](max) NOT NULL,
    [CreatedUtcDateTime] [datetime] NOT NULL,
    [UpdatedUtcDateTime] [datetime] NOT NULL,
    [State] [int] NOT NULL,
    [Remark] [nvarchar](max),
    [CollectionStartUtcDateTime] [datetime] NOT NULL,
    [CollectionEndUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.DevicePathmapStatus] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DeviceProfileDetails] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [DeviceSerial] [nvarchar](max),
    [IotDeviceType] [nvarchar](max),
    [DeviceProfileId] [nvarchar](max),
    CONSTRAINT [PK_dbo.DeviceProfileDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DeviceSupportDetails] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [DeviceSerial] [nvarchar](max),
    [IotDeviceType] [bigint] NOT NULL,
    [SupportDetailsType] [int] NOT NULL,
    [SupportDetailsValue] [nvarchar](max),
    [CreateDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.DeviceSupportDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DeviceTrackers] (
    [Id] [int] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [AccuracyAuditStage] [int],
    [DeviceName] [nvarchar](max),
    [InternalWorkspaceAssignee] [bigint],
    [InternalWorkspaceFollowUpDate] [datetime],
    [InternalWorkspacePriority] [int],
    [InternalWorkspaceStatus] [int],
    [InternalNoteContent] [nvarchar](max),
    [IsTrialCustomer] [bit],
    [LastAllocationDate] [datetime],
    [CommisionProductCode] [nvarchar](max),
    [CaseColour] [nvarchar](max),
    [CameraDegree] [int] NOT NULL,
    [Odoopartnerid] [int],
    [Offline] [int] NOT NULL,
    [PendingIssues] [nvarchar](max),
    [PortalAccountCreation] [nvarchar](max),
    [ResellerId] [bigint],
    [ResellerName] [nvarchar](max),
    [SalesOrderNo] [nvarchar](max),
    [Serial] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [BranchId] [bigint],
    [BranchCode] [nvarchar](max),
    [SiteName] [nvarchar](max),
    [SiteVerifiedDate] [datetime],
    [ChatChannelName] [nvarchar](max),
    [CompanyId] [bigint],
    [V8companyName] [nvarchar](max),
    [WarrantyExpirationDate] [datetime],
    [ExtendedWarrantyDuration] [int] NOT NULL,
    [ProductDisplayName] [nvarchar](max),
    [ProductDescription] [nvarchar](max),
    [FirstAllocationDate] [datetime],
    [FinancialEntityId] [bigint],
    [FinancialEntityName] [nvarchar](max),
    [CurrentLocation] [nvarchar](max),
    [TechnicalAccountManager] [nvarchar](max),
    [BusinessAccountManager] [nvarchar](max),
    [OdooCompanyName] [nvarchar](max),
    [InstallationArrangedBy] [nvarchar](max),
    [Type] [nvarchar](max),
    [Senttoinstaller] [nvarchar](max),
    [DeliveryBusinessAccountManager] [nvarchar](max),
    [SupportChatRoom] [int],
    [WarrantyStatus] [int] NOT NULL,
    [DeviceTrackerStage] [int] NOT NULL,
    [BillingCommencementDate] [datetime],
    [DeviceTrackerStageUpdateDateTime] [datetime],
    [DataMonitoringCompletionDateTime] [datetime],
    [Server] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [LastHeartBeatDateTime] [datetime] NOT NULL,
    [LastOnlineDay] [float] NOT NULL,
    [CustomerProjectID] [nvarchar](max),
    [RMAStage] [int] NOT NULL,
    [RMAOpen] [int] NOT NULL,
    [CameraId] [bigint],
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [DeliveryAddress] [nvarchar](max),
    CONSTRAINT [PK_dbo.DeviceTrackers] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[DeviceUsages] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [ProductType] [int] NOT NULL,
    [DeviceSerial] [nvarchar](max),
    [StartedUtcDateTime] [datetime] NOT NULL,
    [EndedUtcDateTime] [datetime],
    CONSTRAINT [PK_dbo.DeviceUsages] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[DeviceVerificationDetails] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Serial] [nvarchar](max),
    [VerificationStartDateTime] [datetime] NOT NULL,
    [TuningStartDateTime] [datetime] NOT NULL,
    [TuningEndDateTime] [datetime] NOT NULL,
    [CertifiedDateTime] [datetime] NOT NULL,
    [SourceOfNewVerification] [int] NOT NULL,
    [AccuracyDisclaimer] [nvarchar](max),
    CONSTRAINT [PK_dbo.DeviceVerificationDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EmailQueues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Subject] [nvarchar](max),
    [EmailContent] [nvarchar](max),
    [FromEmail] [nvarchar](max),
    [ToEmail] [nvarchar](max),
    [CcEmail] [nvarchar](max),
    [BccEmail] [nvarchar](max),
    [TimeToSend] [datetime] NOT NULL,
    [SenderName] [nvarchar](max),
    [RecipientName] [nvarchar](max),
    [RetryCount] [bigint] NOT NULL,
    [SentDateTime] [datetime],
    [SendStatus] [int] NOT NULL,
    [LastEncounteredError] [nvarchar](max),
    [PathOfAttachments] [nvarchar](max),
    [CompanyID] [bigint],
    CONSTRAINT [PK_dbo.EmailQueues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[EntityAccesses] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [EntityType] [int] NOT NULL,
    [EntityTypeId] [nvarchar](max),
    [Privacy] [nvarchar](max),
    CONSTRAINT [PK_dbo.EntityAccesses] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EntityCommentDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserCommentId] [bigint] NOT NULL,
    [EntityType] [int] NOT NULL,
    [EntityId] [nvarchar](max),
    CONSTRAINT [PK_dbo.EntityCommentDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[EntityProfiles] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ProfileKey] [nvarchar](max),
    [Category] [bigint] NOT NULL,
    [ProfileName] [nvarchar](max),
    [VisibleIn] [nvarchar](max),
    [EntityType] [int] NOT NULL,
    CONSTRAINT [PK_dbo.EntityProfiles] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ESLActionLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [EslItemType] [int] NOT NULL,
    [ItemID] [nvarchar](max),
    [ActionID] [int] NOT NULL,
    [UserID] [int] NOT NULL,
    [OccurredDateTime] [datetime],
    [ActionDetails] [nvarchar](max),
    CONSTRAINT [PK_dbo.ESLActionLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[EslAreaSpaceLinks] (
    [ID] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [EslId] [uniqueidentifier] NOT NULL,
    [AreaId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.EslAreaSpaceLinks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ESLCounterDbms] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [EslTagSerial] [nvarchar](50) NOT NULL,
    [EslTag] [nvarchar](max),
    [CounterSerial] [nvarchar](max),
    [FFCamera] [nvarchar](max),
    [Dbm] [int] NOT NULL,
    [FailCount] [int] NOT NULL,
    CONSTRAINT [PK_dbo.ESLCounterDbms] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EslCustomFieldValues] (
    [Id] [bigint] NOT NULL IDENTITY,
    [EslCustomFieldId] [bigint] NOT NULL,
    [ProductId] [uniqueidentifier] NOT NULL,
    [CustomFieldValue] [nvarchar](max),
    CONSTRAINT [PK_dbo.EslCustomFieldValues] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Events] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [EventType] [int] NOT NULL,
    [EventStartDate] [datetime] NOT NULL,
    [EventEndDate] [datetime] NOT NULL,
    [EvaluationStartDate] [datetime] NOT NULL,
    [EvaluationEndDate] [datetime] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [CreatedUserId] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Events] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EventEntityLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [EventId] [bigint] NOT NULL,
    [GranularityType] [int] NOT NULL,
    [GranularityId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.EventEntityLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EventPeriodSettings] (
    [Id] [bigint] NOT NULL IDENTITY,
    [EventId] [bigint] NOT NULL,
    [EventStartDate] [datetime] NOT NULL,
    [EventEndDate] [datetime] NOT NULL,
    [IsSpecificTime] [bit] NOT NULL,
    [SpecificStartTime] [datetime] NOT NULL,
    [SpecificEndTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.EventPeriodSettings] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EventSettings] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [EventName] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.EventSettings] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[EventTypes] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [CreatedUserId] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [IsActive] [bit] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.EventTypes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ExceptionLogs] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ErrorCode] [nvarchar](50),
    [Method] [nvarchar](max),
    [ExceptionType] [nvarchar](max),
    [ExceptionDetails] [nvarchar](max),
    [OccuredDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.ExceptionLogs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Faces] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [CreatedDateTime] [datetime] NOT NULL,
    [LastUpdatedDateTime] [datetime] NOT NULL,
    [PersonGuid] [uniqueidentifier],
    CONSTRAINT [PK_dbo.Faces] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FavouriteFilters] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [QueryBuilderFilterValue] [nvarchar](max),
    [PageId] [bigint] NOT NULL,
    [UserSource] [int] NOT NULL,
    [UserLevel] [int] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [CanShare] [bit] NOT NULL,
    [IsPageDefaultFavouriteFilter] [bit] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime],
    [ParentFavouriteId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FavouriteFilters] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFAppRecoveries] (
    [Serial] [varchar](30) NOT NULL,
    [IsStaticIP] [bit] NOT NULL,
    [isDHCP] [bit] NOT NULL,
    [IP] [varchar](20),
    [Port] [varchar](10),
    [Subnet] [varchar](20),
    [Gateway] [varchar](20),
    [ProxyAddress] [varchar](250),
    [ProxyPort] [varchar](10),
    [isProxy] [bit] NOT NULL,
    [ProxyUsername] [varchar](30),
    [ProxyPassword] [varchar](30),
    [DNS1] [varchar](20),
    [DNS2] [varchar](20),
    [KeyCode] [nvarchar](30),
    [ServerAddress] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFAppRecoveries] PRIMARY KEY ([Serial])
)
CREATE TABLE [dbo].[FFAreaMinuteCarOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    [IsAggregated] [bit],
    CONSTRAINT [PK_dbo.FFAreaMinuteCarOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFAreaMinuteOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    [IsAggregated] [bit],
    CONSTRAINT [PK_dbo.FFAreaMinuteOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFAreaMinuteStaffOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    [IsAggregated] [bit],
    CONSTRAINT [PK_dbo.FFAreaMinuteStaffOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranch15MinuteValue] (
    [ValueDateTime] [datetime] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Day] [int] NOT NULL,
    [MinuteCount] [int] NOT NULL,
    [CameraCount] [int] NOT NULL,
    [AggregationStatus] [int] NOT NULL,
    [CreatedTimestamp] [bigint] NOT NULL,
    [ModifiedTimestamp] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranch15MinuteValue] PRIMARY KEY ([ValueDateTime], [BranchId])
)
CREATE TABLE [dbo].[FFBranchHourlyMaxStaffOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchHourlyMaxStaffOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchHourlyStaffOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchHourlyStaffOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchMinuteCarOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    [IsAggregated] [bit],
    CONSTRAINT [PK_dbo.FFBranchMinuteCarOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchMinuteOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [StaffOccupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    [IsAggregated] [bit],
    CONSTRAINT [PK_dbo.FFBranchMinuteOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchMinuteStaffOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    [IsAggregated] [bit],
    CONSTRAINT [PK_dbo.FFBranchMinuteStaffOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchOperatingHourArchives] (
    [ID] [bigint] NOT NULL IDENTITY,
    [StartTime] [datetime] NOT NULL,
    [EndTime] [datetime] NOT NULL,
    [Day] [int] NOT NULL,
    [isDayOff] [bit] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchOperatingHourArchives] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchSummaryDailyReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Date] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [OutsideTraffic] [int] NOT NULL,
    [TurnInRate] [float] NOT NULL,
    [FifteenMinWifiCount] [int] NOT NULL,
    [ThirteenMinWifiCount] [int] NOT NULL,
    [OverWifiCount] [int] NOT NULL,
    [NewCustomer] [int] NOT NULL,
    [WeeklyCustomer] [int] NOT NULL,
    [MonthlyCustomer] [int] NOT NULL,
    [CrossOneCustomer] [int] NOT NULL,
    [CrossTwoCustomer] [int] NOT NULL,
    [CrossThreeCustomer] [int] NOT NULL,
    [CrossMoreCustomer] [int] NOT NULL,
    [AverageDwellTime] [float] NOT NULL,
    [TransactionCount] [int] NOT NULL,
    [SalesAmount] [float] NOT NULL,
    [AverageAmount] [float] NOT NULL,
    [SalesConversion] [float] NOT NULL,
    [PatchStatus] [nvarchar](max),
    [IsAggregated] [int] NOT NULL,
    [SalesTarget] [int] NOT NULL,
    [AggregationStatus] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchSummaryDailyReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchSummaryHourlyReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [OutsideTraffic] [int] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [TurnInRate] [real] NOT NULL,
    [Day] [int] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    [ZoneCouting] [int] NOT NULL,
    [HeatMapStay] [int] NOT NULL,
    [HeatMapPassBy] [int] NOT NULL,
    [HeatMapAvgDwell] [real] NOT NULL,
    [ValueIn2] [int] NOT NULL,
    [ValueOut2] [int] NOT NULL,
    [TransactionCount] [int] NOT NULL,
    [SalesAmount] [float] NOT NULL,
    [AverageAmount] [float] NOT NULL,
    [SalesConversion] [float] NOT NULL,
    [IsAggregated] [int] NOT NULL,
    [AggregationStatus] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchSummaryHourlyReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFBranchDailyTargets] (
    [BranchId] [bigint] NOT NULL,
    [Day] [int] NOT NULL,
    [SalesTarget] [int] NOT NULL,
    [CreatedTimestamp] [bigint] NOT NULL,
    [UpdatedTimestamp] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFBranchDailyTargets] PRIMARY KEY ([BranchId], [Day])
)
CREATE TABLE [dbo].[FFCamera15MinuteValue] (
    [ValueDateTime] [datetime] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [Day] [int] NOT NULL,
    [ValueIn2] [int] NOT NULL,
    [ValueOut2] [int] NOT NULL,
    [MinuteCount] [int] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [CreatedTimestamp] [bigint] NOT NULL,
    [ModifiedTimestamp] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCamera15MinuteValue] PRIMARY KEY ([ValueDateTime], [CameraId])
)
CREATE TABLE [dbo].[FFCameraCheckLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [IP] [nvarchar](max),
    [Serial] [nvarchar](max),
    [InternalIP] [nvarchar](max),
    [VpnIP] [nvarchar](max),
    [Reason] [nvarchar](max),
    [TimeLogged] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraCheckLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraCountingRecords] (
    [ID] [bigint] NOT NULL IDENTITY,
    [StartDateTime] [datetime] NOT NULL,
    [StartDateTimeInt] [bigint] NOT NULL,
    [Day] [int] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraCountingRecords] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraCustomerValues] (
    [MAC] [nvarchar](128) NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [HashMac] [nvarchar](max),
    [first_seen] [bigint] NOT NULL,
    [last_seen] [bigint] NOT NULL,
    [count] [int] NOT NULL,
    [dwell_time] [int] NOT NULL,
    [lowest] [int] NOT NULL,
    [highest] [int] NOT NULL,
    [average] [real] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [Day] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraCustomerValues] PRIMARY KEY ([MAC], [ValueDateTime], [CameraId])
)
CREATE TABLE [dbo].[FFCameraCustomerValueArchives] (
    [MAC] [nvarchar](128) NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [HashMac] [nvarchar](max),
    [first_seen] [bigint] NOT NULL,
    [last_seen] [bigint] NOT NULL,
    [count] [int] NOT NULL,
    [monthlycount] [int] NOT NULL,
    [weeklycount] [int] NOT NULL,
    [lastmonthcount] [int] NOT NULL,
    [lastweekcount] [int] NOT NULL,
    [lowest] [int] NOT NULL,
    [highest] [int] NOT NULL,
    [average] [real] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraCustomerValueArchives] PRIMARY KEY ([MAC], [CameraId])
)
CREATE TABLE [dbo].[FFCameraHeatValues] (
    [ValueDateTime] [datetime] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [Value] [nvarchar](max),
    [ValueTimestamp] [datetime] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    [Day] [int] NOT NULL,
    [PatchStatus] [nvarchar](max),
    [ResolutionScale] [int] NOT NULL,
    [HeatMapStay] [int] NOT NULL,
    [HeatMapPassBy] [int] NOT NULL,
    [HeatMapAvgDwell] [float] NOT NULL,
    [ROIHeatMapStay] [int] NOT NULL,
    [ROIHeatMapPassBy] [int] NOT NULL,
    [ROIHeatMapAvgDwell] [float] NOT NULL,
    [CustomerServiceHeatMapAvgDwell] [float] NOT NULL,
    [ROICustomerServiceHeatMapAvgDwell] [float] NOT NULL,
    [StaffRespondTime] [float] NOT NULL,
    [StaffServeTime] [float] NOT NULL,
    [ESLPosition] [nvarchar](max),
    [IsActive] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraHeatValues] PRIMARY KEY ([ValueDateTime], [CameraId])
)
CREATE TABLE [dbo].[FFCameraInstallations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Serial] [nvarchar](max),
    [Remark] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraInstallations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraMinuteValues] (
    [ValueDateTime] [datetime] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [UploadTime] [bigint] NOT NULL,
    [Day] [int] NOT NULL,
    [ValueIn2] [int] NOT NULL,
    [ValueOut2] [int] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [IsAggregated] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraMinuteValues] PRIMARY KEY ([ValueDateTime], [CameraId])
)
CREATE TABLE [dbo].[FFCameraValues] (
    [ValueDateTime] [datetime] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [OutsideTraffic] [int] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    [Day] [int] NOT NULL,
    [PatchStatus] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFCameraValues] PRIMARY KEY ([ValueDateTime], [CameraId])
)
CREATE TABLE [dbo].[FFCameraVerificationStatus] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Reseller] [nvarchar](max),
    [CompanyName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [CameraName] [nvarchar](max),
    [Timezone] [nvarchar](max),
    [OnlineStatus] [nvarchar](max),
    [Version] [nvarchar](max),
    [VerificationStatus] [int] NOT NULL,
    [VerificationStatusExtended] [int] NOT NULL,
    [VerificationCount] [int] NOT NULL,
    [In] [decimal](18, 2) NOT NULL,
    [Out] [decimal](18, 2) NOT NULL,
    [SampleIn] [int] NOT NULL,
    [SampleOut] [int] NOT NULL,
    [ThumbnailPath] [nvarchar](max),
    [ReportPath] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [Serial] [nvarchar](max),
    [Remark] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFCameraVerificationStatus] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraVersions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Version] [nvarchar](max),
    [FileLocation] [nvarchar](max),
    [FileName] [nvarchar](max),
    [MD5] [nvarchar](max),
    [ReleaseDate] [datetime] NOT NULL,
    [Active] [bit] NOT NULL,
    [Downgrade] [bit] NOT NULL,
    [Description] [nvarchar](max),
    [Password] [nvarchar](max),
    [CameraType] [nvarchar](max),
    [BaseVersion] [nvarchar](max),
    [BuiltNumber] [int] NOT NULL,
    [isBetaRelease] [bit] NOT NULL,
    [isReboot] [bit] NOT NULL,
    [isMD5OldMethod] [bit] NOT NULL,
    [IsMD5Match] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraVersions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraWifiThresValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ValueTimestamp] [datetime] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [Fifteen] [int] NOT NULL,
    [Thirty] [int] NOT NULL,
    [Over] [int] NOT NULL,
    [Day] [int] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraWifiThresValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCameraWifiValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Counter] [int] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [Value] [int] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [Day] [int] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCameraWifiValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCCPUpdateZIPDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FileName] [nvarchar](max),
    [MD5] [nvarchar](max),
    [UploadedDateTime] [datetime] NOT NULL,
    [UpdateType] [nvarchar](max),
    [SQL] [nvarchar](max),
    [IsReady] [nvarchar](max),
    [ChangeLog] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFCCPUpdateZIPDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFChatMessages] (
    [FFChatMessageId] [bigint] NOT NULL IDENTITY,
    [FFChatUserId] [bigint] NOT NULL,
    [FFChatRoomId] [bigint] NOT NULL,
    [Message] [nvarchar](max),
    [Time] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFChatMessages] PRIMARY KEY ([FFChatMessageId])
)
CREATE TABLE [dbo].[FFChatRooms] (
    [FFChatRoomId] [bigint] NOT NULL IDENTITY,
    [RoomName] [nvarchar](max),
    [CreatedTime] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFChatRooms] PRIMARY KEY ([FFChatRoomId])
)
CREATE TABLE [dbo].[FFChatRoomMembers] (
    [FFChatRoomMemberId] [bigint] NOT NULL IDENTITY,
    [FFChatRoomId] [bigint] NOT NULL,
    [FFChatUserId] [bigint] NOT NULL,
    [JoinTime] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFChatRoomMembers] PRIMARY KEY ([FFChatRoomMemberId])
)
CREATE TABLE [dbo].[FFChatUsers] (
    [FFChatUserId] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [UserId] [nvarchar](max),
    [DeviceId] [nvarchar](max),
    [DeviceType] [int] NOT NULL,
    [RegistrationTime] [bigint] NOT NULL,
    [IsAdmin] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFChatUsers] PRIMARY KEY ([FFChatUserId])
)
CREATE TABLE [dbo].[FFCommissions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanySerial] [varchar](30),
    [Serial] [varchar](30),
    [CameraName] [nvarchar](30),
    [Port] [int] NOT NULL,
    [isDHCP] [bit] NOT NULL,
    [IP] [varchar](20),
    [Subnet] [varchar](20),
    [Gateway] [varchar](20),
    [DNS1] [varchar](20),
    [DNS2] [varchar](20),
    [ServerAddress] [varchar](250),
    [isProxy] [bit] NOT NULL,
    [ProxyAddress] [varchar](250),
    [ProxyPort] [int] NOT NULL,
    [ProxyUsername] [varchar](30),
    [ProxyPassword] [varchar](30),
    [isFTP] [bit] NOT NULL,
    [FTPAddress] [varchar](250),
    [FTPPort] [int] NOT NULL,
    [FTPUsername] [varchar](30),
    [FTPPassword] [varchar](30),
    [FTPDirectory] [varchar](250),
    [TimeZone] [varchar](50),
    [isNTP] [bit] NOT NULL,
    [NTPServer] [varchar](250),
    [CameraDegree] [int] NOT NULL,
    [CaseColour] [varchar](50),
    [Status] [int] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [Remark] [nvarchar](max),
    [SoldTo] [nvarchar](50),
    [isRMA] [bit] NOT NULL,
    [RMADateTime] [datetime],
    [PrintRequired] [bit] NOT NULL,
    [StoreName] [nvarchar](50),
    [FirmwareVersion] [varchar](10),
    [DeliveryDate] [datetime],
    [RMARemark] [varchar](1000),
    [RepairRemark] [varchar](1000),
    [Warehouse] [varchar](20),
    [RowVersion] rowversion NOT NULL,
    [IsReturn] [bit] NOT NULL,
    [ReturnDate] [datetime] NOT NULL,
    [ReturnTo] [varchar](100),
    [odoo_do_number] [nvarchar](1000),
    [odoo_so_number] [nvarchar](1000),
    [odoo_customer_name] [nvarchar](1000),
    [previous_version] [varchar](1000),
    [RepairRemarkDate] [datetime] NOT NULL,
    [RepairRemarkApprovedBy] [varchar](1000),
    [odoo_partner_id] [bigint] NOT NULL,
    [delivery_address_and_country] [nvarchar](1000),
    [externalRemarkReason] [nvarchar](1000),
    [Variant] [nvarchar](max),
    [RMALocation] [varchar](1000),
    [IsWarrantyCovered] [bit],
    [CMType] [nvarchar](max),
    [IsLoan] [bit] NOT NULL,
    [ProductCode] [nvarchar](max),
    [ComponentID] [nvarchar](max),
    [DefaultDuration] [int] NOT NULL,
    [ExtendedWarrantyDuration] [int] NOT NULL,
    [DeviceTrackerStage] [int] NOT NULL,
    [BillingCommencementDate] [datetime],
    [DeviceTrackerStageUpdateDateTime] [datetime],
    [DataMonitoringCompletionDateTime] [datetime],
    [ProductionStage] [bigint] NOT NULL,
    [ManufacturingOrderName] [nvarchar](max),
    [OdooUserId] [bigint],
    [CustomerProjectID] [nvarchar](max),
    [MacAddress] [nvarchar](max),
    [Grade] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFCommissions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCommissionImages] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ImageUrl] [nvarchar](max),
    [FFCommissionId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCommissionImages] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFCounterCameraHCs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Code] [nvarchar](max),
    [Name] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [Message] [nvarchar](max),
    [ErrorType] [int] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    [CompanyCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [InternalIP] [nvarchar](max),
    [Gateway] [nvarchar](max),
    [Mac] [nvarchar](max),
    [Temp] [nvarchar](max),
    [DateTime] [nvarchar](max),
    [Raspicam] [bit] NOT NULL,
    [Memory] [bigint] NOT NULL,
    [Storage] [bigint] NOT NULL,
    [CountingData] [bit] NOT NULL,
    [WifiData] [bit] NOT NULL,
    [NTP] [bit] NOT NULL,
    [Softether] [nvarchar](max),
    [LastBoot] [nvarchar](max),
    [Version] [nvarchar](max),
    [DHCP] [bit] NOT NULL,
    [IsVideoUploaded] [bit] NOT NULL,
    [Serial] [nvarchar](max),
    [DatabaseStatus] [nvarchar](max),
    [NetworkStatus] [nvarchar](max),
    [VoltageStatus] [nvarchar](max),
    [SoftetherIP] [nvarchar](max),
    [cameraError] [nvarchar](max),
    [isFTP] [nvarchar](max),
    [isFTPUploaded] [nvarchar](max),
    [ErrorCode] [nvarchar](max),
    [ErrorMessage] [nvarchar](max),
    [Wifi] [bit] NOT NULL,
    [floorSpaceLog] [nvarchar](max),
    [humanDetectLog] [nvarchar](max),
    [objectLog] [nvarchar](max),
    [HeartbeatLog] [nvarchar](max),
    [PatchVersion] [nvarchar](max),
    [DStorage] [bigint] NOT NULL,
    [counterCurrentDateTimeTimezone] [nvarchar](max),
    [counterCurrentHostsIP] [nvarchar](max),
    [OccupancyStatusLog] [nvarchar](max),
    [lastHeartbeatBackhaul] [nvarchar](max),
    [Protocol] [nvarchar](max),
    [RaspicamStatusLog] [nvarchar](max),
    [CheckWebServerState] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFCounterCameraHCs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFCrossShoppers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Week] [int] NOT NULL,
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimeStamp] [bigint] NOT NULL,
    [NoCrossShop] [int] NOT NULL,
    [CrossOneShop] [int] NOT NULL,
    [CrossTwoShop] [int] NOT NULL,
    [CrossThreeShop] [int] NOT NULL,
    [CrossFourShop] [int] NOT NULL,
    [CrossMultipleShop] [int] NOT NULL,
    [TotalCrossShop] [int] NOT NULL,
    [TotalValueIn] [int] NOT NULL,
    [TotalValueOut] [int] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCrossShoppers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFDashboards] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [DashboardName] [nvarchar](max),
    [DateTimeCreated] [datetime] NOT NULL,
    [DateTimeLastUpdated] [datetime] NOT NULL,
    [SortOrder] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFDashboards] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFDashboardDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [DashboardId] [bigint] NOT NULL,
    [DashboardTitle] [nvarchar](max),
    [FromDate] [nvarchar](max),
    [ToDate] [nvarchar](max),
    [BranchCode] [nvarchar](max),
    [Parameter1] [nvarchar](max),
    [Parameter2] [nvarchar](max),
    [Parameter3] [nvarchar](max),
    [DateTimeCreated] [datetime] NOT NULL,
    [DateTimeLastUpdated] [datetime] NOT NULL,
    [SortOrder] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFDashboardDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFEmailReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReportId] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [CompanyCode] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [BranchName] [nvarchar](max),
    [UserId] [int] NOT NULL,
    [Email] [nvarchar](max),
    [SendTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FFEmailReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReportName] [nvarchar](max),
    [SortOrder] [int] NOT NULL,
    [Description] [nvarchar](max),
    [Link] [nvarchar](max),
    [RoleAccess] [nvarchar](max),
    [Frequency] [nvarchar](max),
    [Status] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFEPosStaffHours] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Serial] [nvarchar](max),
    [CameraId] [bigint] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    [StaffCount] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFEPosStaffHours] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFEPosTransactionDatas] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchCode] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    [TransactionCount] [int] NOT NULL,
    [SalesAmount] [float] NOT NULL,
    [AverageAmount] [float] NOT NULL,
    [TransactionCount2] [int] NOT NULL,
    [SalesAmount2] [float] NOT NULL,
    [AverageAmount2] [float] NOT NULL,
    [TransactionCount3] [int] NOT NULL,
    [SalesAmount3] [float] NOT NULL,
    [AverageAmount3] [float] NOT NULL,
    [PatchStatus] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFEPosTransactionDatas] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFRecentViews] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [LastView] [datetime] NOT NULL,
    [ReportType] [nvarchar](max),
    [ReportLink] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFRecentViews] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFRecoveries] (
    [Serial] [varchar](30) NOT NULL,
    [ServerAddress] [nvarchar](max),
    [isDHCP] [bit] NOT NULL,
    [IP] [varchar](20),
    [Subnet] [varchar](20),
    [Gateway] [varchar](20),
    [DateRetrieved] [datetime],
    [dns1] [varchar](20),
    [dns2] [varchar](20),
    [isActive] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFRecoveries] PRIMARY KEY ([Serial])
)
CREATE TABLE [dbo].[FFRemoteAccesses] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserName] [nvarchar](max),
    [Password] [nvarchar](max),
    [dateCreated] [datetime] NOT NULL,
    [dateExpired] [datetime] NOT NULL,
    [companyCode] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFRemoteAccesses] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFReportSummaryDailies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Date] [bigint] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [CameraName] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [ValueIn] [int] NOT NULL,
    [ValueOut] [int] NOT NULL,
    [OutsideTraffic] [int] NOT NULL,
    [TurnInRate] [float] NOT NULL,
    [FifteenMinWifiCount] [int] NOT NULL,
    [ThirteenMinWifiCount] [int] NOT NULL,
    [OverWifiCount] [int] NOT NULL,
    [NewCustomer] [int] NOT NULL,
    [WeeklyCustomer] [int] NOT NULL,
    [MonthlyCustomer] [int] NOT NULL,
    [CustomerMacs] [nvarchar](max),
    [WeeklyCustomerMacs] [nvarchar](max),
    [MonthlyCustomerMacs] [nvarchar](max),
    [AverageDwellTime] [float] NOT NULL,
    [CrossShopper1] [int] NOT NULL,
    [CrossShopper2] [int] NOT NULL,
    [CrossShopper3] [int] NOT NULL,
    [TopCrossShop1] [bigint] NOT NULL,
    [TopCrossShop2] [bigint] NOT NULL,
    [TopCrossShop3] [bigint] NOT NULL,
    [PatchStatus] [nvarchar](max),
    [IsAggregated] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFReportSummaryDailies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFServers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ServerName] [nvarchar](max),
    [FFServerIP] [nvarchar](max),
    [ServerGUID] [nvarchar](max),
    [ResellerCompanyCode] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [LastHeartBeat] [bigint] NOT NULL,
    [Version] [nvarchar](max),
    [SBVersion] [nvarchar](max),
    [ShouldUpdate] [bit] NOT NULL,
    [ShouldUpdateSB] [bit] NOT NULL,
    [LastBackupDateTime] [datetime] NOT NULL,
    [BackupFileName] [nvarchar](max),
    [FFCCPUsage] [nvarchar](max),
    [AllDBTableUsageDetails] [nvarchar](max),
    [ServerDriveInformation] [nvarchar](max),
    [ServerAddress] [nvarchar](max),
    [AggregationStatus] [nvarchar](max),
    [EmailAddress] [nvarchar](max),
    [FirmwareReleaseStatus] [nvarchar](max),
    [PageAccess] [nvarchar](max),
    [ResellerID] [nvarchar](max),
    [SchedulerVersion] [nvarchar](max),
    [SchedulerLastHeartBeat] [datetime] NOT NULL,
    [CounterSoftPatchReleaseStatus] [nvarchar](max),
    [ShouldReboot] [bit] NOT NULL,
    [DatabaseInformation] [nvarchar](max),
    [ServerShortId] [nvarchar](max),
    [Remark] [nvarchar](max),
    [IsRetailCamModuleDBCreated] [bit] NOT NULL,
    [IsRetailCamModuleInstall] [bit] NOT NULL,
    [RetailCamModuleLastHeartBeat] [datetime],
    CONSTRAINT [PK_dbo.FFServers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFVideoScheduleLogRemarks] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FFVideoScheduleId] [bigint] NOT NULL,
    [LogRemarkDateTime] [datetime] NOT NULL,
    [CountIn] [int] NOT NULL,
    [CountOut] [int] NOT NULL,
    [Remark] [nvarchar](max),
    CONSTRAINT [PK_dbo.FFVideoScheduleLogRemarks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFZoneRelations] (
    [ValueDateTime] [datetime] NOT NULL,
    [SourceZoneId] [bigint] NOT NULL,
    [TargetZoneId] [bigint] NOT NULL,
    [Value] [int] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFZoneRelations] PRIMARY KEY ([ValueDateTime], [SourceZoneId], [TargetZoneId])
)
CREATE TABLE [dbo].[FinancialEntities] (
    [Id] [bigint] NOT NULL IDENTITY,
    [FeId] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [IsParent] [bit] NOT NULL,
    [DisplayName] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.FinancialEntities] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FirmwarePatchReleaseAuthentications] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FirmwarePatchVersion] [nvarchar](max),
    [Type] [nvarchar](max),
    [Stage] [nvarchar](max),
    [Value] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [BetaCounterSerial] [nvarchar](max),
    CONSTRAINT [PK_dbo.FirmwarePatchReleaseAuthentications] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FirmwareStages] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FirmwareID] [bigint] NOT NULL,
    [FirmwareName] [nvarchar](max),
    [Stage] [nvarchar](max),
    [MaxAPICall] [int] NOT NULL,
    [CurrentAPICalled] [int] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [CreatedBy] [nvarchar](max),
    [IsJSONFileGenerate] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FirmwareStages] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FolderSubscribers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReportFolderID] [bigint] NOT NULL,
    [UserID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FolderSubscribers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FootfallCam3DMiniDetail] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CreatedDateTime] [datetime] NOT NULL,
    [IoTDeviceSerial] [nvarchar](max),
    CONSTRAINT [PK_dbo.FootfallCam3DMiniDetail] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FutureVideoScheduleJobs] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Serial] [nvarchar](max),
    [AllocationDateTime] [datetime] NOT NULL,
    [JobCompleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FutureVideoScheduleJobs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[GeneralActionLogs] (
    [Id] [uniqueidentifier] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [UserSource] [int] NOT NULL,
    [ServerGuid] [uniqueidentifier] NOT NULL,
    [Action] [nvarchar](max),
    [ActionDetails] [nvarchar](max),
    [OccuredDateTime] [datetime] NOT NULL,
    [EntityName] [nvarchar](max),
    [ReferenceId] [nvarchar](max),
    [ModuleName] [nvarchar](max),
    CONSTRAINT [PK_dbo.GeneralActionLogs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[GraviteeLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [LogUploadDateTime] [datetime] NOT NULL,
    [apiCallDateTime] [datetime] NOT NULL,
    [plan] [nvarchar](max),
    [application] [nvarchar](max),
    [path] [nvarchar](max),
    [method] [nvarchar](max),
    [status] [int] NOT NULL,
    [responsetime] [int] NOT NULL,
    CONSTRAINT [PK_dbo.GraviteeLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[GtfsAgencies] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [agency_id] [nvarchar](max),
    [agency_name] [nvarchar](max) NOT NULL,
    [agency_url] [nvarchar](max) NOT NULL,
    [agency_timezone] [nvarchar](max) NOT NULL,
    [agency_lang] [nvarchar](max),
    [agency_phone] [nvarchar](max),
    [agency_fare_url] [nvarchar](max),
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsAgencies] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[GtfsCalendars] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [service_id] [nvarchar](max) NOT NULL,
    [monday] [int] NOT NULL,
    [tuesday] [int] NOT NULL,
    [wednesday] [int] NOT NULL,
    [thursday] [int] NOT NULL,
    [friday] [int] NOT NULL,
    [saturday] [int] NOT NULL,
    [sunday] [int] NOT NULL,
    [start_date] [datetime] NOT NULL,
    [end_date] [datetime] NOT NULL,
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsCalendars] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[GtfsCalendarDates] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [service_id] [nvarchar](max) NOT NULL,
    [date] [datetime] NOT NULL,
    [exception_type] [int] NOT NULL,
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsCalendarDates] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[GtfsRoutes] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [route_id] [nvarchar](max) NOT NULL,
    [agency_id] [nvarchar](max),
    [route_short_name] [nvarchar](max),
    [route_long_name] [nvarchar](max),
    [route_desc] [nvarchar](max),
    [route_type] [int] NOT NULL,
    [route_url] [nvarchar](max),
    [route_color] [nvarchar](max),
    [route_text_color] [nvarchar](max),
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsRoutes] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[GtfsShapes] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [shape_id] [nvarchar](max) NOT NULL,
    [shape_pt_lat] [float] NOT NULL,
    [shape_pt_lon] [float] NOT NULL,
    [shape_pt_sequence] [int] NOT NULL,
    [shape_dist_traveled] [real] NOT NULL,
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsShapes] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[GtfsStops] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [stop_id] [nvarchar](max) NOT NULL,
    [stop_code] [nvarchar](max),
    [stop_name] [nvarchar](max),
    [stop_desc] [nvarchar](max),
    [stop_lat] [float] NOT NULL,
    [stop_lon] [float] NOT NULL,
    [zone_id] [nvarchar](max),
    [stop_url] [nvarchar](max),
    [location_type] [int] NOT NULL,
    [parent_station] [nvarchar](max),
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsStops] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[GtfsStopTimes] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [trip_id] [nvarchar](max),
    [arrival_time] [nvarchar](max),
    [departure_time] [nvarchar](max),
    [stop_id] [nvarchar](max),
    [stop_sequence] [int] NOT NULL,
    [stop_headsign] [nvarchar](max),
    [pickup_type] [int] NOT NULL,
    [drop_off_type] [int] NOT NULL,
    [shape_dist_traveled] [real] NOT NULL,
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsStopTimes] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[GtfsTrips] (
    [id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [route_id] [nvarchar](max),
    [service_id] [nvarchar](max),
    [trip_id] [nvarchar](max) NOT NULL,
    [trip_headsign] [nvarchar](max),
    [trip_short_name] [nvarchar](max),
    [direction_id] [int] NOT NULL,
    [block_id] [nvarchar](max),
    [shape_id] [nvarchar](max),
    [wheelchair_accessible] [int] NOT NULL,
    [company_id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.GtfsTrips] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[HotspotEmails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [email] [nvarchar](max),
    [serial] [nvarchar](max),
    [emailCreated] [datetime] NOT NULL,
    [rowCreated] [datetime] NOT NULL,
    [hotspotMac] [nvarchar](max),
    CONSTRAINT [PK_dbo.HotspotEmails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[HotspotSettings] (
    [CompanyId] [bigint] NOT NULL,
    [WifiSSID] [nvarchar](max),
    [WifiChannel] [int] NOT NULL,
    [FRSecret] [nvarchar](max),
    [FRClient] [nvarchar](max),
    [CNetwork] [nvarchar](max),
    [CNetMask] [nvarchar](max),
    [CUAMListen] [nvarchar](max),
    [CUAMPort] [int] NOT NULL,
    [CUAMUIPort] [int] NOT NULL,
    [CCOAPort] [int] NOT NULL,
    [CDNS1] [nvarchar](max),
    [CDNS2] [nvarchar](max),
    [CRadius] [nvarchar](max),
    [CRadius2] [nvarchar](max),
    [CUAMAllow] [nvarchar](max),
    [CSecret] [nvarchar](max),
    [CUAMDomains] [nvarchar](max),
    [CMACAuth] [bit] NOT NULL,
    [CMACPassword] [nvarchar](max),
    [CPTnC] [nvarchar](max),
    [CPbackgroundIMG] [nvarchar](max),
    [CPIcon] [nvarchar](max),
    [isSettingAdjusted] [bit] NOT NULL,
    [settingAdjustedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.HotspotSettings] PRIMARY KEY ([CompanyId])
)
CREATE TABLE [dbo].[IncidentLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Serial] [nvarchar](max),
    [LogLevel] [nvarchar](max),
    [DateTime] [datetime] NOT NULL,
    [Category] [nvarchar](max),
    [Type] [nvarchar](max),
    [IssueLog] [nvarchar](max),
    [LogUploadedDateTime] [datetime] NOT NULL,
    [DeviceType] [nvarchar](max),
    CONSTRAINT [PK_dbo.IncidentLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Industries] (
    [Id] [bigint] NOT NULL IDENTITY,
    [IndustryStringValue] [nvarchar](max),
    [UpdatedDateTime] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Industries] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[IoTDevices] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CreateDateTime] [datetime] NOT NULL,
    [Serial] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [DeviceName] [nvarchar](max),
    [FirmwareVersion] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [LastHeartbeatDateTimeUTC] [datetime] NOT NULL,
    [IoTDeviceType] [nvarchar](max),
    [AllocationDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.IoTDevices] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ITSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [IsStaticIP] [bit] NOT NULL,
    [IP] [varchar](20),
    [Port] [int] NOT NULL,
    [Subnet] [varchar](20),
    [Gateway] [varchar](20),
    [DNS1] [varchar](20),
    [DNS2] [varchar](20),
    [isProxy] [bit] NOT NULL,
    [ProxyAddress] [varchar](250),
    [ProxyPort] [int] NOT NULL,
    [ProxyUsername] [varchar](30),
    [ProxyPassword] [varchar](30),
    [KeyCode] [nvarchar](30),
    [CounterKeyCode] [nvarchar](max),
    [CounterReplace] [int] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [ResellerCompanyCode] [nvarchar](max),
    [Server] [nvarchar](max),
    [MTU] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    CONSTRAINT [PK_dbo.ITSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Jetsons] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Serial] [nvarchar](max),
    [Name] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [Server] [nvarchar](max),
    [QueueServerAddress] [nvarchar](max),
    [LiveOccServerAddress] [nvarchar](max),
    [IP] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [Version] [nvarchar](max),
    [PatchVersion] [nvarchar](max),
    [DriveThruStart] [bit] NOT NULL,
    [SpaceOccupancyStart] [bit] NOT NULL,
    [Softether] [bit] NOT NULL,
    [DateUpdated] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [CreatedDate] [datetime] NOT NULL,
    [UpdateFlag] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Jetsons] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[JetsonCCTVs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [JetsonID] [bigint] NOT NULL,
    [Name] [nvarchar](max),
    [Type] [int] NOT NULL,
    [IP] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    [CreatedDate] [datetime] NOT NULL,
    [DateUpdated] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.JetsonCCTVs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[JetsonCommissions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanySerial] [nvarchar](max),
    [Serial] [nvarchar](max),
    [Status] [int] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [RowVersion] [varbinary](max),
    [Remark] [nvarchar](max),
    [isRMA] [bit] NOT NULL,
    [RMADateTime] [datetime],
    [RMARemark] [nvarchar](max),
    [RepairRemark] [nvarchar](max),
    [Warehouse] [nvarchar](max),
    [IsReturn] [bit] NOT NULL,
    [ReturnDate] [datetime] NOT NULL,
    [ReturnTo] [nvarchar](max),
    [odoo_do_number] [nvarchar](max),
    [odoo_so_number] [nvarchar](max),
    [odoo_customer_name] [nvarchar](max),
    [previous_version] [nvarchar](max),
    [RepairRemarkDate] [datetime] NOT NULL,
    [RepairRemarkApprovedBy] [nvarchar](max),
    [odoo_partner_id] [bigint] NOT NULL,
    [delivery_address_and_country] [nvarchar](max),
    [externalRemarkReason] [nvarchar](max),
    [Variant] [nvarchar](max),
    [RMALocation] [nvarchar](max),
    [IsWarrantyCovered] [bit],
    [isLoan] [bit] NOT NULL,
    [ProductCode] [nvarchar](max),
    CONSTRAINT [PK_dbo.JetsonCommissions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[JetsonCountingHourlies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [JetsonSerial] [nvarchar](max),
    [Date] [datetime] NOT NULL,
    [CalculateMethod] [nvarchar](max),
    [LiveCountRefreshRate] [int] NOT NULL,
    [CountersCount] [int] NOT NULL,
    [unixTimestamp] [int] NOT NULL,
    [localTimestamp] [int] NOT NULL,
    [UpdateTimestamp] [int] NOT NULL,
    [PeopleCount] [int] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.JetsonCountingHourlies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[JetsonHealthChecks] (
    [id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Serial] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [Softether] [nvarchar](max),
    [SoftetherIP] [nvarchar](max),
    [DriveThruStart] [bit] NOT NULL,
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [InternalIP] [nvarchar](max),
    [Gateway] [nvarchar](max),
    [DHCP] [bit] NOT NULL,
    [Temp] [nvarchar](max),
    [Wifi] [bit] NOT NULL,
    [Memory] [nvarchar](max),
    [Storage] [nvarchar](max),
    [Version] [nvarchar](max),
    [PatchVersion] [nvarchar](max),
    [DateTime] [nvarchar](max),
    [Timestamp] [bigint] NOT NULL,
    [LastBoot] [nvarchar](max),
    [Message] [nvarchar](max),
    CONSTRAINT [PK_dbo.JetsonHealthChecks] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[JetsonQueueCountings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CCTVID] [bigint] NOT NULL,
    [Timestamp] [int] NOT NULL,
    [CCTVType] [int] NOT NULL,
    [QueueTime] [real] NOT NULL,
    [ServeTime] [real] NOT NULL,
    [Carplate] [nvarchar](max),
    CONSTRAINT [PK_dbo.JetsonQueueCountings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[LinkShorteners] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Url] [nvarchar](max),
    [ShortenUrl] [nvarchar](max),
    [CreationDateTime] [datetime] NOT NULL,
    [HasDomain] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.LinkShorteners] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[LinkShortenerLinkages] (
    [Id] [bigint] NOT NULL IDENTITY,
    [LinkItemId] [bigint],
    [LinkShortenerId] [bigint] NOT NULL,
    [UsageType] [nvarchar](max),
    CONSTRAINT [PK_dbo.LinkShortenerLinkages] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MagicMirrorAggregatedDatas] (
    [Id] [int] NOT NULL IDENTITY,
    [DeviceId] [uniqueidentifier] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [CreatedDataTime] [datetime] NOT NULL,
    [ButtonClicked] [bigint] NOT NULL,
    [TakePhoto] [bigint] NOT NULL,
    [PreviewPhoto] [bigint] NOT NULL,
    [Share] [bigint] NOT NULL,
    [Submit] [bigint] NOT NULL,
    [LinkClicked] [bigint] NOT NULL,
    [CategoryClicked] [bigint] NOT NULL,
    [ItemClicked] [bigint] NOT NULL,
    [Search] [bigint] NOT NULL,
    [ShowLayout] [bigint] NOT NULL,
    [NavigateApp] [bigint] NOT NULL,
    [ActionLog] [bigint] NOT NULL,
    [EmailSend] [bigint] NOT NULL,
    [EventStartTime] [bigint] NOT NULL,
    [EventEndTime] [bigint] NOT NULL,
    [MediaUpload] [bigint] NOT NULL,
    [FacebookSharing] [bigint] NOT NULL,
    [TwitterSharing] [bigint] NOT NULL,
    [InstagramSharing] [bigint] NOT NULL,
    [DownloadSharing] [bigint] NOT NULL,
    [ViewingAnalytics] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.MagicMirrorAggregatedDatas] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MagicMirrorCompanyLinks] (
    [RowId] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [MirrorId] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.MagicMirrorCompanyLinks] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[MarketingCampaigns] (
    [Id] [uniqueidentifier] NOT NULL,
    [CampaignName] [nvarchar](max),
    CONSTRAINT [PK_dbo.MarketingCampaigns] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MarketingCampaignPeriods] (
    [MarketingCampaignId] [uniqueidentifier] NOT NULL,
    [CampaignStartDate] [datetime] NOT NULL,
    [CampaignEndDate] [datetime] NOT NULL,
    [IsSpecificTime] [bit] NOT NULL,
    [SpecificStartTime] [datetime] NOT NULL,
    [SpecificEndTime] [datetime] NOT NULL,
    [CampaignRecurrence] [int] NOT NULL,
    [ComparisonPeriodBefore] [int] NOT NULL,
    [ComparisonPeriodAfter] [int] NOT NULL,
    CONSTRAINT [PK_dbo.MarketingCampaignPeriods] PRIMARY KEY ([MarketingCampaignId])
)
CREATE TABLE [dbo].[MarketingCampaignRecurringDays] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [MarketingCampaignId] [uniqueidentifier] NOT NULL,
    [RecurringDay] [int] NOT NULL,
    CONSTRAINT [PK_dbo.MarketingCampaignRecurringDays] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MarketingCampaignSites] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [MarketingCampaignId] [uniqueidentifier] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.MarketingCampaignSites] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MarketingTrackerReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [companyID] [bigint] NOT NULL,
    [Name] [nvarchar](max),
    [startDate] [datetime] NOT NULL,
    [endDate] [datetime] NOT NULL,
    [Budget] [float] NOT NULL,
    [compare] [bit] NOT NULL,
    [creationDate] [datetime] NOT NULL,
    [compareTargetID] [bigint] NOT NULL,
    [comment] [nvarchar](max),
    [Initiatives] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.MarketingTrackerReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MarketingTrackerReportSiteLists] (
    [ID] [bigint] NOT NULL IDENTITY,
    [MarketingTrackerReportID] [bigint] NOT NULL,
    [branchID] [bigint] NOT NULL,
    [areaID] [bigint],
    [isDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.MarketingTrackerReportSiteLists] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MacExclusions] (
    [Id] [bigint] NOT NULL IDENTITY,
    [StaffId] [nvarchar](max),
    [MacAddress] [nvarchar](max),
    [AddedType] [int] NOT NULL,
    [CreatedDate] [datetime] NOT NULL,
    [DeletedDate] [datetime],
    [IsDeleted] [bit] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    CONSTRAINT [PK_dbo.MacExclusions] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Media] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Duration] [real] NOT NULL,
    [FilePath] [nvarchar](max),
    [Name] [nvarchar](max),
    [Type] [nvarchar](max),
    [SubType] [nvarchar](max),
    [Size] [real] NOT NULL,
    [UploadTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.Media] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MessageJobs] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [MessageType] [int] NOT NULL,
    [MessageObject] [nvarchar](max),
    [SendDateTime] [datetime] NOT NULL,
    [Status] [int] NOT NULL,
    CONSTRAINT [PK_dbo.MessageJobs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MessageQueues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyID] [bigint],
    [Content] [nvarchar](max),
    [FromSender] [nvarchar](max),
    [ToRecipient] [nvarchar](max),
    [Source] [nvarchar](max),
    [TimeToSend] [datetime] NOT NULL,
    [RetryCount] [bigint] NOT NULL,
    [SentDateTime] [datetime],
    [SendStatus] [int] NOT NULL,
    [LastEncounteredError] [nvarchar](max),
    [PathOfAttachments] [nvarchar](max),
    [Subject] [nvarchar](max),
    [Cc] [nvarchar](max),
    [Bcc] [nvarchar](max),
    [SenderName] [nvarchar](max),
    [RecipientName] [nvarchar](max),
    [Discriminator] [nvarchar](128) NOT NULL,
    CONSTRAINT [PK_dbo.MessageQueues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MethodExecutionDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ControllerName] [nvarchar](max),
    [MethodName] [nvarchar](max),
    [TimeTaken] [bigint] NOT NULL,
    [ExecutedCount] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.MethodExecutionDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MetricDetails] (
    [Id] [bigint] NOT NULL IDENTITY,
    [MetricCode] [nvarchar](max),
    [MetricName] [nvarchar](max),
    [ReferenceKey] [nvarchar](max),
    [MetricDescription] [nvarchar](max),
    [HeroicGuideLink] [nvarchar](max),
    [MetricOutputFormat] [nvarchar](max),
    CONSTRAINT [PK_dbo.MetricDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MetricTypes] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Details] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.MetricTypes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[MiniComputers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Serial] [nvarchar](max),
    [Name] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [Server] [nvarchar](max),
    [IP] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [Version] [nvarchar](max),
    [PatchVersion] [nvarchar](max),
    [Softether] [bit] NOT NULL,
    [DateUpdated] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [CreatedDate] [datetime] NOT NULL,
    [UpdateFlag] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.MiniComputers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MiniComputerCommissions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanySerial] [nvarchar](max),
    [Serial] [nvarchar](max),
    [Status] [int] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    [Remark] [nvarchar](max),
    [isRMA] [bit] NOT NULL,
    [RMADateTime] [datetime],
    [RMARemark] [nvarchar](max),
    [RepairRemark] [nvarchar](max),
    [Warehouse] [nvarchar](max),
    [IsReturn] [bit] NOT NULL,
    [ReturnDate] [datetime] NOT NULL,
    [odoo_do_number] [nvarchar](max),
    [odoo_so_number] [nvarchar](max),
    [odoo_customer_name] [nvarchar](max),
    [previous_version] [nvarchar](max),
    [RepairRemarkDate] [datetime] NOT NULL,
    [RepairRemarkApprovedBy] [nvarchar](max),
    [odoo_partner_id] [bigint] NOT NULL,
    [delivery_address_and_country] [nvarchar](max),
    [externalRemarkReason] [nvarchar](max),
    [Variant] [nvarchar](max),
    [RMALocation] [nvarchar](max),
    [IsWarrantyCovered] [bit],
    [IsLoan] [bit] NOT NULL,
    [ProductCode] [nvarchar](max),
    CONSTRAINT [PK_dbo.MiniComputerCommissions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MiniComputerHealthChecks] (
    [id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Serial] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [CompanySerial] [nvarchar](max),
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [Softether] [nvarchar](max),
    [SoftetherIP] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [InternalIP] [nvarchar](max),
    [Gateway] [nvarchar](max),
    [DHCP] [bit] NOT NULL,
    [Temp] [nvarchar](max),
    [Wifi] [bit] NOT NULL,
    [Memory] [nvarchar](max),
    [Storage] [nvarchar](max),
    [Version] [nvarchar](max),
    [PatchVersion] [nvarchar](max),
    [DateTime] [nvarchar](max),
    [Timestamp] [bigint] NOT NULL,
    [LastBoot] [nvarchar](max),
    [Message] [nvarchar](max),
    [Server] [nvarchar](max),
    CONSTRAINT [PK_dbo.MiniComputerHealthChecks] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[MinuteOccupancyValues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [MetricCode] [nvarchar](50),
    [Type] [int] NOT NULL,
    [TypeId] [nvarchar](50),
    [ValueDateTime] [datetime] NOT NULL,
    [ValueTimestamp] [datetime] NOT NULL,
    [OperateStatus] [nvarchar](max),
    [Occupancy] [int] NOT NULL,
    [PreCountOccupancy] [int] NOT NULL,
    [PLCountOccupancy] [int] NOT NULL,
    CONSTRAINT [PK_dbo.MinuteOccupancyValues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Miscellaneous] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Key] [nvarchar](max),
    [Value] [nvarchar](max),
    CONSTRAINT [PK_dbo.Miscellaneous] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMBranches] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyCode] [nvarchar](max),
    [BranchID] [int] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [SoftwareName] [nvarchar](max),
    [EmailTitle] [nvarchar](max),
    [EmailDescription] [nvarchar](max),
    [EmailLocation] [nvarchar](max),
    [Status] [bit] NOT NULL,
    [EmailFbAlbumName] [nvarchar](max),
    [EmailFbAlbumDescription] [nvarchar](max),
    [EmailFbAlbumLocation] [nvarchar](max),
    [BranchEmail] [nvarchar](max),
    [EmailImageFolderName] [nvarchar](max),
    [EmailHTMLTemplateFolderName] [nvarchar](max),
    [EmailHTMLTemplateName] [nvarchar](max),
    [UpdatedDate] [datetime] NOT NULL,
    [BranchWebsite] [nvarchar](max),
    [IsFacebook] [bit] NOT NULL,
    [IsTwitter] [bit] NOT NULL,
    [IsPinterest] [bit] NOT NULL,
    [IsWeiBo] [bit] NOT NULL,
    [MMLogFileName] [nvarchar](max),
    [SocialMediaVersion] [int] NOT NULL,
    [TwitterDescription] [nvarchar](max),
    [MagicMirrorVersion] [nvarchar](max),
    [MagicMirrorConfigFile] [nvarchar](max),
    [Logo] [nvarchar](max),
    [Watermark] [nvarchar](max),
    [PromotionalText1] [nvarchar](max),
    [PromotionalImage1] [nvarchar](max),
    [PromotionalURL1] [nvarchar](max),
    [PromotionalText2] [nvarchar](max),
    [PromotionalImage2] [nvarchar](max),
    [PromotionalURL2] [nvarchar](max),
    [PromotionalText3] [nvarchar](max),
    [PromotionalImage3] [nvarchar](max),
    [PromotionalURL3] [nvarchar](max),
    [PromotionalText4] [nvarchar](max),
    [PromotionalImage4] [nvarchar](max),
    [PromotionalURL4] [nvarchar](max),
    [EmailCustomizationVersion] [nvarchar](max),
    [EmailCustomizationStatus] [nvarchar](max),
    [EmailCustomizationLastUpdate] [bigint] NOT NULL,
    [SocialMediaCustomizationVersion] [nvarchar](max),
    [SocialMediaCustomizationStatus] [nvarchar](max),
    [SocialMediaCustomizationLastUpdate] [bigint] NOT NULL,
    [PhotoFrameCSVVersion] [nvarchar](max),
    [PhotoFrameCSVStatus] [nvarchar](max),
    [PhotoFrameCSVLastUpdate] [bigint] NOT NULL,
    [PhotoFrameCSVLocation] [bigint] NOT NULL,
    [PhotoFrameImageVersion] [nvarchar](max),
    [PhotoFrameImageStatus] [nvarchar](max),
    [PhotoFrameImageLastUpdate] [bigint] NOT NULL,
    [PhotoFrameImageLocation] [bigint] NOT NULL,
    [VideoVersion] [nvarchar](max),
    [VideoStatus] [nvarchar](max),
    [VideoLastUpdate] [bigint] NOT NULL,
    [VideoLocation] [bigint] NOT NULL,
    [ProductCSVVersion] [nvarchar](max),
    [ProductCSVStatus] [nvarchar](max),
    [ProductCSVLastUpdate] [bigint] NOT NULL,
    [ProductCSVLocation] [bigint] NOT NULL,
    [ProductImageVersion] [nvarchar](max),
    [ProductImageStatus] [nvarchar](max),
    [ProductImageLastUpdate] [bigint] NOT NULL,
    [ProductImageLocation] [bigint] NOT NULL,
    [VoucherVersion] [nvarchar](max),
    [VoucherStatus] [nvarchar](max),
    [VoucherLastUpdate] [bigint] NOT NULL,
    [VoucherLocation] [bigint] NOT NULL,
    [MagicMirrorVersionStatus] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMBranches] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMCameraSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [Mode] [nvarchar](max),
    [ISO] [nvarchar](max),
    [AV] [nvarchar](max),
    [TV] [nvarchar](max),
    [UpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.MMCameraSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMCameraSettingAEModes] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AEModeValue] [nvarchar](max),
    [AEModeText] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMCameraSettingAEModes] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMCameraSettingAVs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [AVValue] [nvarchar](max),
    [AVText] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMCameraSettingAVs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMCameraSettingISOes] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ISOValue] [nvarchar](max),
    [ISOText] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMCameraSettingISOes] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMCameraSettingTVs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [TVValue] [nvarchar](max),
    [TVText] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMCameraSettingTVs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMCustomizationSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [EmailCustomizationVersion] [nvarchar](max),
    [SocialMediaCustomizationVersion] [nvarchar](max),
    [PhotoFrameCSVVersion] [nvarchar](max),
    [PhotoFrameImageVersion] [nvarchar](max),
    [VideoVersion] [nvarchar](max),
    [ProductCSVVersion] [nvarchar](max),
    [ProductImageVersion] [nvarchar](max),
    [VoucherVersion] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMCustomizationSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMFacebookPhotoGalleries] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [ImageLocation] [nvarchar](max),
    [ImageURL] [nvarchar](max),
    [UserId] [uniqueidentifier] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [OriginalImageLocation] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMFacebookPhotoGalleries] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMHealthChecks] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [Message] [nvarchar](max),
    [Timestamp] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.MMHealthChecks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserId] [uniqueidentifier] NOT NULL,
    [CompanyId] [int] NOT NULL,
    [CompanyName] [nvarchar](max),
    [BranchId] [int] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [MMVersionId] [int] NOT NULL,
    [MMVersionType] [nvarchar](max),
    [MMVersionName] [nvarchar](max),
    [TakePhoto] [bit] NOT NULL,
    [EmailAddress] [nvarchar](max),
    [CustomerName] [nvarchar](max),
    [PhoneNumber] [nvarchar](max),
    [YearOfBirth] [int] NOT NULL,
    [MonthOfBirth] [int] NOT NULL,
    [DayOfBirth] [int] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [City] [nvarchar](max),
    [Country] [nvarchar](max),
    [PreferredCommunicationFrequency] [nvarchar](max),
    [PreferredCommunicationTypes] [nvarchar](max),
    [PreferredCommunicationLanguage] [nvarchar](max),
    [DataSource] [nvarchar](max),
    [Other] [nvarchar](max),
    [Score] [int] NOT NULL,
    [Rank] [int] NOT NULL,
    [PostToFacebook] [bit] NOT NULL,
    [FacebookId] [nvarchar](max),
    [FacebookUsername] [nvarchar](max),
    [PostToTwitter] [bit] NOT NULL,
    [TwitterId] [nvarchar](max),
    [TwitterUsername] [nvarchar](max),
    [PrintVoucher] [bit] NOT NULL,
    [ItemBrowse] [nvarchar](max),
    [KinectInterpretation] [nvarchar](max),
    [PhotoFiles] [nvarchar](max),
    [SendEmail] [bit] NOT NULL,
    [Disclaimer] [bit] NOT NULL,
    [CustomerIdentifier] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMModules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ModuleName] [nvarchar](max),
    [BranchId] [int] NOT NULL,
    CONSTRAINT [PK_dbo.MMModules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMModuleCompanies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ModuleTypeId] [bigint] NOT NULL,
    [CompanyCode] [nvarchar](max),
    [Description] [nvarchar](max),
    [AppId] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMModuleCompanies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMModuleTypes] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ModuleName] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMModuleTypes] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMPhotoGalleryDeletedImages] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [FileName] [nvarchar](max),
    [UserId] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.MMPhotoGalleryDeletedImages] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMUploadTasks] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyCode] [nvarchar](max),
    [AppId] [nvarchar](max),
    [Version] [float] NOT NULL,
    [Data] [nvarchar](max),
    [Description] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [DeployDateTime] [datetime] NOT NULL,
    [Status] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMUploadTasks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMVersions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyCode] [nvarchar](max),
    [BranchID] [int] NOT NULL,
    [BranchCode] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [SoftwareName] [nvarchar](max),
    [Version] [float] NOT NULL,
    [Status] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMVersions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[MMWebPhotoGalleries] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [nvarchar](max),
    [BranchName] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [ImageLocation] [nvarchar](max),
    [ImageURL] [nvarchar](max),
    [UserId] [uniqueidentifier] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [OriginalImageLocation] [nvarchar](max),
    CONSTRAINT [PK_dbo.MMWebPhotoGalleries] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ModifySchedules] (
    [Id] [bigint] NOT NULL IDENTITY,
    [StaffId] [bigint] NOT NULL,
    [StartDateTime] [datetime] NOT NULL,
    [EndDateTime] [datetime] NOT NULL,
    [BreakStartTime] [datetime],
    [BreakEndTime] [datetime],
    [Type] [int],
    [IsOffDay] [bit],
    [TotalWage] [float] NOT NULL,
    CONSTRAINT [PK_dbo.ModifySchedules] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[NCDVRHCs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Code] [nvarchar](max),
    [Name] [nvarchar](max),
    [ExternalIP] [nvarchar](max),
    [ExternalPort] [nvarchar](max),
    [Message] [nvarchar](max),
    [ErrorType] [int] NOT NULL,
    [Timestamp] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.NCDVRHCs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[NetworkDiagnostics] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DeviceID] [nvarchar](max),
    [ReportID] [bigint] NOT NULL,
    [UTCDateTime] [datetime] NOT NULL,
    [OnlineStatus] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.NetworkDiagnostics] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[Notifications] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [MessageContent] [nvarchar](max),
    [NotificationDateTime] [datetime] NOT NULL,
    [NotificationType] [int] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [ReadDateTime] [datetime],
    CONSTRAINT [PK_dbo.Notifications] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[NotificationEventLogs] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Type] [int] NOT NULL,
    [TypeId] [nvarchar](max),
    [NotificationMessageId] [uniqueidentifier] NOT NULL,
    [BreachValue] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.NotificationEventLogs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[NotificationMessages] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [MessageContent] [nvarchar](max),
    [NotificationDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.NotificationMessages] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[NotificationGateways] (
    [branchid] [bigint] NOT NULL,
    [NotificationType] [nvarchar](max),
    [TelegramGroupID] [nvarchar](max),
    [TriggerType] [nvarchar](max),
    [Threshold] [int] NOT NULL,
    [MessageOutput] [nvarchar](max),
    [isActive] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.NotificationGateways] PRIMARY KEY ([branchid])
)
CREATE TABLE [dbo].[NotificationGatewayHistories] (
    [id] [bigint] NOT NULL IDENTITY,
    [branchid] [bigint] NOT NULL,
    [cameraid] [bigint] NOT NULL,
    [duration] [nvarchar](max),
    [Threshold] [int] NOT NULL,
    [Message] [nvarchar](max),
    [DateTime] [datetime] NOT NULL,
    [TriggerType] [nvarchar](max),
    [TriggerTypeDetails] [nvarchar](max),
    [status] [nvarchar](max),
    CONSTRAINT [PK_dbo.NotificationGatewayHistories] PRIMARY KEY ([id])
)
CREATE TABLE [dbo].[NotificationGatewayThresholds] (
    [cameraid] [bigint] NOT NULL,
    [telegram_threshold] [int] NOT NULL,
    CONSTRAINT [PK_dbo.NotificationGatewayThresholds] PRIMARY KEY ([cameraid])
)
CREATE TABLE [dbo].[NotificationTypes] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Type] [nvarchar](max),
    [Details] [nvarchar](max),
    [NotificationTriggersId] [bigint],
    CONSTRAINT [PK_dbo.NotificationTypes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[NotificationUserLinks] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [NotificationMessageId] [uniqueidentifier] NOT NULL,
    [UserId] [bigint],
    [ReadStatus] [int] NOT NULL,
    [ReadStatusUpdatedDateTime] [datetime],
    [NotificationReadSource] [int],
    [DeviceId] [nvarchar](max),
    CONSTRAINT [PK_dbo.NotificationUserLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[OccupancyDataManualLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ModifiedDate] [datetime] NOT NULL,
    [Value] [int] NOT NULL,
    [CameraSerial] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [DataLevel] [int] NOT NULL,
    [DataID] [nvarchar](max),
    [Status] [bit] NOT NULL,
    [ErrorMessage] [nvarchar](max),
    CONSTRAINT [PK_dbo.OccupancyDataManualLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[OfflineSimSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Serial] [varchar](30),
    [IsDownloaded] [bit] NOT NULL,
    [LastUpdateDate] [datetime],
    [LastAccessedDate] [datetime],
    [Email] [nvarchar](max),
    [TuningType] [nvarchar](max),
    [SBStatus] [int] NOT NULL,
    [GenerateVerificationReport] [int] NOT NULL,
    [VerificationRemark] [nvarchar](max),
    [VerificationResultFileName] [nvarchar](max),
    CONSTRAINT [PK_dbo.OfflineSimSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[OpenTickets] (
    [Id] [bigint] NOT NULL IDENTITY,
    [TicketId] [uniqueidentifier] NOT NULL,
    [CompanySerial] [nvarchar](max),
    [Serial] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [IsTicketOpen] [bit] NOT NULL,
    [TicketType] [int] NOT NULL,
    [TicketPrefixId] [nvarchar](max),
    [ServerGuid] [nvarchar](max),
    CONSTRAINT [PK_dbo.OpenTickets] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFPageAccesses] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [Page] [int] NOT NULL,
    [DefaultUserAccess] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFPageAccesses] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFPageAccessCompanies] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [Page] [int] NOT NULL,
    [DefaultUserAccess] [bit] NOT NULL,
    [DefaultAdminAccess] [bit] NOT NULL,
    [DefaultResellerAccess] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.FFPageAccessCompanies] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Pages] (
    [ID] [int] NOT NULL IDENTITY,
    [pageID] [int] NOT NULL,
    [ActionName] [nvarchar](max),
    [ControllerName] [nvarchar](max),
    [Description] [nvarchar](max),
    [Logo] [nvarchar](max),
    [Group] [nvarchar](max),
    [UserDefault] [bit] NOT NULL,
    [AdminDefault] [bit] NOT NULL,
    [ResellerDefault] [bit] NOT NULL,
    [CompanyDefault] [bit] NOT NULL,
    [paramString] [nvarchar](max),
    [sortOrder] [int] NOT NULL,
    [subGroup] [nvarchar](max),
    [AccType] [nvarchar](max),
    [DefaultPage] [nvarchar](max),
    [emailSchedulerStatus] [int] NOT NULL,
    [frequency] [nvarchar](max),
    [reportType] [nvarchar](max),
    [GroupSort] [int] NOT NULL,
    [reportLevel] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [MetaOnly] [bit] NOT NULL,
    [TelerikModelName] [varchar](50),
    CONSTRAINT [PK_dbo.Pages] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ParentDeviceLinks] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CameraId] [bigint] NOT NULL,
    [ParentCameraId] [bigint] NOT NULL,
    [Sequence] [int] NOT NULL,
    [CreatedUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.ParentDeviceLinks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[PatchStages] (
    [ID] [bigint] NOT NULL IDENTITY,
    [PatchID] [bigint] NOT NULL,
    [PatchName] [nvarchar](max),
    [Stage] [nvarchar](max),
    [MaxAPICall] [int] NOT NULL,
    [CurrentAPICalled] [int] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [CreatedBy] [nvarchar](max),
    [IsJSONFileGenerate] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.PatchStages] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SoftPatches] (
    [ID] [bigint] NOT NULL IDENTITY,
    [PatchVersion] [nvarchar](max),
    [FileLocation] [nvarchar](max),
    [FileName] [nvarchar](max),
    [MD5] [nvarchar](max),
    [ReleaseDate] [datetime] NOT NULL,
    [Active] [bit] NOT NULL,
    [Description] [nvarchar](max),
    [Password] [nvarchar](max),
    [BuiltNumber] [int] NOT NULL,
    [cameraVersionBuiltNumber] [int] NOT NULL,
    [isReboot] [bit] NOT NULL,
    [IsMD5Match] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.SoftPatches] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Policies] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [Name] [nvarchar](max),
    [EntityType] [nvarchar](max),
    [DefaultValue] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Policies] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[PolicyApplications] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [PolicyId] [uniqueidentifier] NOT NULL,
    [EntityType] [nvarchar](max),
    [EntityId] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [Value] [bit] NOT NULL,
    [AllowOverride] [bit] NOT NULL,
    [CreatedUtcDateTime] [datetime] NOT NULL,
    [UpdatedUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.PolicyApplications] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[PrecountTrainLogs] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [Type] [int] NOT NULL,
    [TypeId] [bigint] NOT NULL,
    [PrecountType] [int] NOT NULL,
    [CreateDateTime] [datetime] NOT NULL,
    [PrecountTrainingStatus] [int] NOT NULL,
    [Log] [nvarchar](max),
    CONSTRAINT [PK_dbo.PrecountTrainLogs] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[PredictiveAnalyzationValues] (
    [Id] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [CreatedDateTime] [datetime],
    [TimeGranularity] [nvarchar](max),
    [MetricCode] [nvarchar](max),
    [PredictionDateTime] [datetime],
    [Prediction] [float] NOT NULL,
    [PredictionLower] [float] NOT NULL,
    [PredictionUpper] [float] NOT NULL,
    [ConfidenceLevel] [int] NOT NULL,
    [CameraSerial] [nvarchar](max),
    CONSTRAINT [PK_dbo.PredictiveAnalyzationValues] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductCodes] (
    [ID] [bigint] NOT NULL IDENTITY,
    [productCode] [nvarchar](max),
    [productType] [nvarchar](max),
    [description] [nvarchar](max),
    CONSTRAINT [PK_dbo.ProductCodes] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ProductCurrencyPrices] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [ProductId] [uniqueidentifier] NOT NULL,
    [Currency] [nvarchar](max),
    [OriginalPrice] [float] NOT NULL,
    [DiscountedPrice] [float] NOT NULL,
    [IsCompanyLevel] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.ProductCurrencyPrices] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductCustomizableFields] (
    [Id] [bigint] NOT NULL IDENTITY,
    [FieldKey] [nvarchar](max),
    [FieldValue] [nvarchar](max),
    [ProductId] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.ProductCustomizableFields] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductCustomPrices] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [ProductId] [uniqueidentifier] NOT NULL,
    [Currency] [nvarchar](max),
    [OriginalPrice] [float] NOT NULL,
    [DiscountedPrice] [float] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [ProductCurrencyPriceId] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.ProductCustomPrices] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductDetails] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ProductCode] [nvarchar](max),
    [ProductDisplayName] [nvarchar](max),
    CONSTRAINT [PK_dbo.ProductDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProductLineManagements] (
    [ID] [bigint] NOT NULL IDENTITY,
    [featureRequestSubject] [nvarchar](max),
    [featureRequestMessage] [nvarchar](max),
    [featureRequestImage] [nvarchar](max),
    [footfallCamComment] [nvarchar](max),
    [requestStatus] [nvarchar](max),
    [featureRequestVersion] [nvarchar](max),
    [createdDate] [nvarchar](max),
    [companyID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ProductLineManagements] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ProductSupportServicePrices] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ProductType] [int] NOT NULL,
    [Price] [decimal](18, 2) NOT NULL,
    [ServicePlanId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ProductSupportServicePrices] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ProjectTrackers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [IssueDate] [nvarchar](max),
    [IssueDetails] [nvarchar](max),
    [IssueRemarks] [nvarchar](max),
    [IssueStatus] [nvarchar](max),
    [ResellerID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ProjectTrackers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[PublicHolidays] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Country] [nvarchar](max),
    [CountryAbbr] [nvarchar](max),
    [PublicHolidayName] [nvarchar](max),
    [DateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.PublicHolidays] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[PublicHolidaysByStates] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Country] [nvarchar](max),
    [CountryAbbr] [nvarchar](max),
    [State] [nvarchar](max),
    [PublicHolidayName] [nvarchar](max),
    [DateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.PublicHolidaysByStates] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[PublicUrlAccesses] (
    [Guid] [uniqueidentifier] NOT NULL,
    [Type] [int] NOT NULL,
    [Parameters] [nvarchar](max),
    [SessionHelper] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.PublicUrlAccesses] PRIMARY KEY ([Guid])
)
CREATE TABLE [dbo].[PulsarItems] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [PurposeType] [int] NOT NULL,
    [IsCompleted] [bit] NOT NULL,
    [Type] [int] NOT NULL,
    [TypeId] [bigint] NOT NULL,
    [CreationDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime],
    [IsDisabled] [bit] NOT NULL,
    [ExtraInformation] [nvarchar](max),
    CONSTRAINT [PK_dbo.PulsarItems] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[QuerySchedulerEntities] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [QueryName] [nvarchar](max),
    [ConnectionName] [nvarchar](max),
    [SerializedDataSource] [nvarchar](max),
    [QueryString] [nvarchar](max),
    [AccessToken] [nvarchar](max),
    [QueryType] [nvarchar](max),
    CONSTRAINT [PK_dbo.QuerySchedulerEntities] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[queueCountings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [timestamp] [int] NOT NULL,
    [DateTime] [datetime] NOT NULL,
    [serveTime] [real] NOT NULL,
    [queueTime] [real] NOT NULL,
    [lastServeTime] [int] NOT NULL,
    [cameraID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.queueCountings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[QueuePredictions] (
    [Id] [bigint] NOT NULL IDENTITY,
    [AreaId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [PredictionDateTime] [datetime],
    [ArrivalRate] [float],
    [ServiceRate] [float],
    [NumberOfCashiers] [int],
    [SalesConversion] [float],
    [ShoppingDuration] [float],
    [PredictionMethod] [nvarchar](max),
    [PredictionQueueTime] [float],
    [PredictionQueueLength] [float],
    [PredictionQueueAndServeTime] [float],
    CONSTRAINT [PK_dbo.QueuePredictions] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[QueueUsageSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CameraId] [bigint] NOT NULL,
    [QueueUsageType] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime],
    CONSTRAINT [PK_dbo.QueueUsageSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[RemoteAccessDetails] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanySerial] [nvarchar](max),
    [IsRemoteAccessEnabled] [bit] NOT NULL,
    [RemoteAccessUsername] [nvarchar](max),
    [RemoteAccessConnectionStartDateTime] [datetime],
    [RemoteAccessURL] [nvarchar](max),
    CONSTRAINT [PK_dbo.RemoteAccessDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[RemoteReportGenerations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReportName] [nvarchar](max),
    [ServerGUID] [nvarchar](max),
    [BranchID] [bigint] NOT NULL,
    [GenerationStatus] [nvarchar](max),
    [RowCreatedDateTime] [datetime] NOT NULL,
    [ReportSelectedDate] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.RemoteReportGenerations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ReportDashboardTags] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [ReportDashboardTagTypeID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ReportDashboardTags] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ReportDashboardTagTypes] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ReportDashboardTagTypes] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ReportFrequentTables] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReportFrequencyId] [bigint] NOT NULL,
    [ReportId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ReportFrequentTables] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ReportSchedulerEntities] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReportId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ReportSchedulerEntities] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ReportSchedulerSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [SchedulerEntityType] [nvarchar](max),
    [SchedulerEntityId] [nvarchar](max),
    [ReportId] [bigint] NOT NULL,
    [Schedule] [datetime] NOT NULL,
    [Active] [bit] NOT NULL,
    [OutputTemplate] [nvarchar](max),
    [Frequency] [bigint] NOT NULL,
    [FrequencyValue] [nvarchar](max),
    [ReportPeriod] [bigint] NOT NULL,
    [Recipients] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ReportSchedulerSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ReportSubscribers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CustomReportID] [bigint] NOT NULL,
    [UserID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ReportSubscribers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Resellers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CountryId] [nvarchar](max),
    [CountryName] [nvarchar](max),
    [ResellerCompanyName] [nvarchar](max),
    [ContactPerson] [nvarchar](max),
    [Address] [nvarchar](max),
    [EmailAddress] [nvarchar](max),
    [ContactNumber] [nvarchar](max),
    [Description] [nvarchar](max),
    [MSRP] [nvarchar](max),
    [Url] [nvarchar](max),
    [ResellerPrice] [nvarchar](max),
    [Priority] [nvarchar](max),
    [LogoURL] [nvarchar](max),
    [UrlDisplay] [nvarchar](max),
    CONSTRAINT [PK_dbo.Resellers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ReturnMerchandiseAuthorisations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CounterSerial] [nvarchar](max),
    [RMAIssue] [nvarchar](max),
    [RMADate] [nvarchar](max),
    [FootfallCamRemarks] [nvarchar](max),
    [RMAStatus] [nvarchar](max),
    [ResellerID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.ReturnMerchandiseAuthorisations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Rules] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [RuleType] [int] NOT NULL,
    [Params] [nvarchar](max),
    [IsActive] [bit] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [MetaData] [nvarchar](max),
    [CreatedUtcDateTime] [datetime] NOT NULL,
    [CreatedByUserEmail] [nvarchar](max),
    [Status] [nvarchar](max),
    [Application] [nvarchar](max),
    CONSTRAINT [PK_dbo.Rules] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[RuleEngineActions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Gateway] [int] NOT NULL,
    [Payload] [nvarchar](max),
    [RuleId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.RuleEngineActions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[RuleObjects] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [RuleName] [nvarchar](max),
    [CreationDateTime] [datetime] NOT NULL,
    [UpdateDateTime] [datetime],
    CONSTRAINT [PK_dbo.RuleObjects] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[SalesLeads] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CustomerCompanyName] [nvarchar](max),
    [PotentialRemarks] [nvarchar](max),
    [Country] [nvarchar](max),
    [ExpiryDate] [nvarchar](max),
    [SalesLeadStatus] [nvarchar](max),
    [FootfallCamRemarks] [nvarchar](max),
    [ResellerID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.SalesLeads] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SalesTransactions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Date] [datetime] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [TransactionCount] [int] NOT NULL,
    [SalesAmount] [float] NOT NULL,
    CONSTRAINT [PK_dbo.SalesTransactions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SchedulerJobs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [JobName] [nvarchar](max),
    [JobSchedule] [nvarchar](30),
    [Active] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.SchedulerJobs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SensorGatewayLinks] (
    [ID] [bigint] NOT NULL IDENTITY,
    [GatewaySerial] [nvarchar](max),
    [SensorSerial] [nvarchar](max),
    CONSTRAINT [PK_dbo.SensorGatewayLinks] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SerialCounters] (
    [ID] [bigint] NOT NULL IDENTITY,
    [SerialCount] [bigint] NOT NULL,
    [Prefix] [nvarchar](max),
    [RowVersion] rowversion NOT NULL,
    CONSTRAINT [PK_dbo.SerialCounters] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ServerIdentifications] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ServerName] [nvarchar](max),
    [GUID] [nvarchar](max),
    [ResellerCompanyCode] [nvarchar](max),
    [CompanyCode] [nvarchar](max),
    [ShouldUpdate] [bit] NOT NULL,
    [ServerAddress] [nvarchar](max),
    [AggregationStatus] [nvarchar](max),
    [EmailAddress] [nvarchar](max),
    [FirmwareReleaseStatus] [nvarchar](max),
    [PageAccess] [nvarchar](max),
    [counterFirmwareReleaseConfig] [nvarchar](max),
    [counterBetaFirmwareReleaseConfig] [nvarchar](max),
    [CounterSoftPatchReleaseStatus] [nvarchar](max),
    CONSTRAINT [PK_dbo.ServerIdentifications] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[ServiceSubscriptions] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [ServiceDetailId] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [CreationDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.ServiceSubscriptions] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[SessionManagements] (
    [Id] [nvarchar](128) NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [LastUpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.SessionManagements] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ShiftPreferences] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [GranularityType] [int] NOT NULL,
    [GranularityId] [nvarchar](max),
    [Name] [nvarchar](max),
    [StartTime] [datetime] NOT NULL,
    [EndTime] [datetime] NOT NULL,
    [ShiftId] [nvarchar](max),
    CONSTRAINT [PK_dbo.ShiftPreferences] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ShiftWages] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [GranularityType] [int] NOT NULL,
    [GranularityId] [nvarchar](max),
    [SolutionId] [int] NOT NULL,
    [Wage] [float] NOT NULL,
    [WageType] [int] NOT NULL,
    [ShiftId] [nvarchar](max),
    CONSTRAINT [PK_dbo.ShiftWages] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[FFShopperHourlyValues] (
    [ValueDateTime] [datetime] NOT NULL,
    [CameraId] [bigint] NOT NULL,
    [MAC] [nvarchar](128) NOT NULL,
    [HashMac] [nvarchar](max),
    [first_seen] [bigint] NOT NULL,
    [last_seen] [bigint] NOT NULL,
    [status] [int] NOT NULL,
    [Day] [int] NOT NULL,
    CONSTRAINT [PK_dbo.FFShopperHourlyValues] PRIMARY KEY ([ValueDateTime], [CameraId], [MAC])
)
CREATE TABLE [dbo].[SiteDiscrepancySummaries] (
    [Id] [bigint] NOT NULL IDENTITY,
    [SiteId] [bigint] NOT NULL,
    [AreaId] [bigint] NOT NULL,
    [DayNumber] [int] NOT NULL,
    [DiscrepancyPercentage] [real],
    [IsBreached] [bit],
    CONSTRAINT [PK_dbo.SiteDiscrepancySummaries] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[SiteHealthChecks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Type] [int] NOT NULL,
    [TypeId] [nvarchar](max),
    [MetricCode] [nvarchar](max),
    [AnalyzeType] [int] NOT NULL,
    [Score] [float],
    [EventOccuredDateTime] [datetime] NOT NULL,
    [EventEndDateTime] [datetime],
    [AnalyzeDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.SiteHealthChecks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[SiteNotesForCustomers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [NoteContent] [nvarchar](max),
    [OdooId] [bigint] NOT NULL,
    [CreateDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.SiteNotesForCustomers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SitePendingIssues] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [SiteIssueId] [nvarchar](max),
    CONSTRAINT [PK_dbo.SitePendingIssues] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SiteProfileDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [SiteProfileId] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [ServerGuid] [nvarchar](max),
    CONSTRAINT [PK_dbo.SiteProfileDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SiteSupportDetails] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [SupportDetailsType] [int] NOT NULL,
    [SupportDetailsValue] [nvarchar](max),
    [CreateDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.SiteSupportDetails] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[SiteTags] (
    [ID] [bigint] NOT NULL IDENTITY,
    [branchID] [bigint] NOT NULL,
    [tagName] [nvarchar](max),
    CONSTRAINT [PK_dbo.SiteTags] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SiteTargetPlanningWorkspaces] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [CompanyTargetPlanningId] [bigint] NOT NULL,
    [BranchId] [bigint] NOT NULL,
    [Changes] [float] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [CreatedBy] [bigint] NOT NULL,
    [SalesVolume] [float] NOT NULL,
    [SalesConversion] [float] NOT NULL,
    [NoOfUnitsPerTransaction] [float] NOT NULL,
    [Footfall] [int] NOT NULL,
    [NoOfTransactions] [int] NOT NULL,
    [NoOfUnitsSold] [int] NOT NULL,
    [AverageSalesVolumePerFootfall] [float] NOT NULL,
    [AverageSalesVolumePerTransaction] [float] NOT NULL,
    [AveragePricePerUnit] [float] NOT NULL,
    CONSTRAINT [PK_dbo.SiteTargetPlanningWorkspaces] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SiteVerificationDetails] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchId] [bigint] NOT NULL,
    [SiteLastTunedDateTime] [datetime] NOT NULL,
    [SiteLastCertifiedDateTime] [datetime] NOT NULL,
    [ReadinessForSiteQC] [bit] NOT NULL,
    [CertifiedBy] [nvarchar](max),
    CONSTRAINT [PK_dbo.SiteVerificationDetails] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[SmartbinDatas] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CameraSerial] [nvarchar](max),
    [TagID] [nvarchar](max),
    [dbm] [real] NOT NULL,
    [TagVoltage] [real] NOT NULL,
    [TagDateTime] [datetime] NOT NULL,
    [tofData] [real] NOT NULL,
    [CounterDateTime] [datetime] NOT NULL,
    [CounterDateTimeUTC] [datetime] NOT NULL,
    [UploadedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.SmartbinDatas] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Staffs] (
    [Id] [bigint] NOT NULL IDENTITY,
    [FirstName] [nvarchar](max),
    [LastName] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [UserName] [nvarchar](max),
    [ShiftPreferenceId] [bigint] NOT NULL,
    [MaxWorkingHour] [int] NOT NULL,
    [MinWorkingHour] [int] NOT NULL,
    [EmployeeId] [nvarchar](max),
    [Wage] [float],
    [SiteId] [bigint],
    [IsActive] [bit],
    CONSTRAINT [PK_dbo.Staffs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[StaffHours] (
    [ID] [bigint] NOT NULL IDENTITY,
    [BranchCode] [nvarchar](max),
    [Timestamp] [bigint] NOT NULL,
    [StaffCount] [float] NOT NULL,
    [branchId] [bigint] NOT NULL,
    [PatchStatus] [nvarchar](max),
    CONSTRAINT [PK_dbo.StaffHours] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[StaffRelationLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [GranularityType] [int] NOT NULL,
    [GranularityId] [nvarchar](max),
    [StaffEmployeeId] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.StaffRelationLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[StandardizedLoginAttemptLogs] (
    [Id] [bigint] NOT NULL IDENTITY,
    [AttemptDateTime] [datetime] NOT NULL,
    [AttemptStatus] [bit] NOT NULL,
    [Stage] [int] NOT NULL,
    [Message] [nvarchar](max),
    [StandardizedLoginStatusId] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.StandardizedLoginAttemptLogs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[StandardizedLoginStatus] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [DeviceType] [int] NOT NULL,
    [LoginSource] [int] NOT NULL,
    [LoginAccountType] [bigint] NOT NULL,
    [Status] [int] NOT NULL,
    [Username] [nvarchar](max),
    [SNonce] [nvarchar](max),
    [SNonceDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.StandardizedLoginStatus] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[SuggestedSchedules] (
    [Id] [bigint] NOT NULL IDENTITY,
    [StaffId] [bigint] NOT NULL,
    [StartDateTime] [datetime] NOT NULL,
    [EndDateTime] [datetime] NOT NULL,
    [BreakStartTime] [datetime],
    [BreakEndTime] [datetime],
    [Type] [int],
    [IsOffDay] [bit],
    [TotalWage] [float] NOT NULL,
    CONSTRAINT [PK_dbo.SuggestedSchedules] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[SupportServicePlans] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ServerGuid] [nvarchar](max),
    [CompanyId] [bigint] NOT NULL,
    [Name] [nvarchar](max),
    [BasePlanId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.SupportServicePlans] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[SystemSettings] (
    [ID] [bigint] NOT NULL IDENTITY,
    [SettingName] [nvarchar](500),
    [SettingValue] [nvarchar](500),
    CONSTRAINT [PK_dbo.SystemSettings] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[TargetPlanningWorkspaces] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [StartCampaignPeriod] [datetime] NOT NULL,
    [EndCampaignPeriod] [datetime] NOT NULL,
    [StartBenchmarkPeriod] [datetime] NOT NULL,
    [EndBenchmarkPeriod] [datetime] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [CreatedBy] [bigint] NOT NULL,
    [SalesVolume] [float] NOT NULL,
    [SalesConversion] [float] NOT NULL,
    [NoOfUnitsPerTransaction] [float] NOT NULL,
    [Footfall] [int] NOT NULL,
    [NoOfTransactions] [int] NOT NULL,
    [NoOfUnitsSold] [int] NOT NULL,
    [AverageSalesVolumePerFootfall] [float] NOT NULL,
    [AverageSalesVolumePerTransaction] [float] NOT NULL,
    [AveragePricePerUnit] [float] NOT NULL,
    CONSTRAINT [PK_dbo.TargetPlanningWorkspaces] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[TaskObjects] (
    [RowId] [bigint] NOT NULL IDENTITY,
    [TaskName] [nvarchar](max),
    [RuleId] [bigint] NOT NULL,
    [IsDisabled] [bit] NOT NULL,
    [NextTaskName] [nvarchar](max),
    [CreationDateTime] [datetime] NOT NULL,
    [UpdateDateTime] [datetime],
    CONSTRAINT [PK_dbo.TaskObjects] PRIMARY KEY ([RowId])
)
CREATE TABLE [dbo].[TempDBActivityLogs] (
    [ID] [bigint] NOT NULL IDENTITY,
    [SnapShotTimestamp] [datetime] NOT NULL,
    [SnapShotGUID] [uniqueidentifier] NOT NULL,
    [SessionID] [int] NOT NULL,
    [DatabaseName] [nvarchar](128),
    [SystemName] [nvarchar](128),
    [ProgramName] [nvarchar](128),
    [UserName] [nvarchar](128),
    [HostProcessID] [int],
    [ClientInterfaceName] [nvarchar](50),
    [Status] [nvarchar](30),
    [CPUTimeMS] [int] NOT NULL,
    [TotalScheduledTimeMS] [int] NOT NULL,
    [ElapsedTimeMS] [int] NOT NULL,
    [MemoryUsageKB] [int],
    [SpaceAllocatedForUserObjKB] [bigint],
    [SpaceDeallocatedForUserObjKB] [bigint],
    [SpaceAllocatedForInternalObjKB] [bigint],
    [SpaceDeallocatedForInternalObjKB] [bigint],
    [SessionType] [nvarchar](14),
    [RowCount] [bigint] NOT NULL,
    [SQLText] [nvarchar](max),
    CONSTRAINT [PK_dbo.TempDBActivityLogs] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[UpdateControls] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Control] [nvarchar](max),
    [Value] [nvarchar](max),
    CONSTRAINT [PK_dbo.UpdateControls] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[UserComments] (
    [ID] [bigint] NOT NULL IDENTITY,
    [Type] [int] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [UserId] [bigint] NOT NULL,
    [Comment] [nvarchar](max),
    [CreatedUtcDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.UserComments] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[UserCPIs] (
    [Id] [bigint] NOT NULL IDENTITY,
    [DateTime] [datetime] NOT NULL,
    [UserName] [nvarchar](128),
    [PageName] [nvarchar](128),
    CONSTRAINT [PK_dbo.UserCPIs] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserDefinedImportFileHeaderMappings] (
    [Id] [uniqueidentifier] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [MappingDetails] [nvarchar](max),
    [RowCreatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.UserDefinedImportFileHeaderMappings] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserDevices] (
    [Id] [bigint] NOT NULL IDENTITY,
    [EmailAddress] [nvarchar](max),
    [DeviceId] [nvarchar](max),
    [MobileAppId] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdatedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.UserDevices] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserEntityAccessLinks] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [EntityAccessId] [uniqueidentifier] NOT NULL,
    [UserId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.UserEntityAccessLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[ConfigurationUserGroups] (
    [Id] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [UserGroupName] [nvarchar](max),
    [Hierarchy] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [DeletedDateTime] [datetime],
    [UpdatedDateTime] [datetime],
    CONSTRAINT [PK_dbo.ConfigurationUserGroups] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserGroupSettings] (
    [Id] [bigint] NOT NULL IDENTITY,
    [ConfigurationUserGroupId] [bigint] NOT NULL,
    [UserActionId] [int] NOT NULL,
    [CreateAccess] [bit] NOT NULL,
    [ReadAccess] [bit] NOT NULL,
    [UpdateAccess] [bit] NOT NULL,
    [DeleteAccess] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.UserGroupSettings] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserGroupLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [ConfigurationUserGroupId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.UserGroupLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[UserSiteGroupLinks] (
    [Id] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [SiteGroupId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.UserSiteGroupLinks] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[VCountCredentials] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CompanyCode] [nvarchar](max) NOT NULL,
    [UserName] [nvarchar](max) NOT NULL,
    [Password] [nvarchar](max) NOT NULL,
    [Timezone] [nvarchar](max) NOT NULL,
    CONSTRAINT [PK_dbo.VCountCredentials] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[Vehicles] (
    [Id] [nvarchar](128) NOT NULL,
    [LicensePlate] [nvarchar](max),
    [BranchId] [bigint] NOT NULL,
    [DriverId] [bigint] NOT NULL,
    [VehicleName] [nvarchar](max),
    [IsDeleted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.Vehicles] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[VerificationReports] (
    [ID] [bigint] NOT NULL IDENTITY,
    [CameraId] [bigint] NOT NULL,
    [ReportId] [bigint] NOT NULL,
    [Serial] [varchar](30),
    [Filenames] [nvarchar](max),
    [VerifiedBy] [nvarchar](30),
    [AdditionalComment] [nvarchar](max),
    [ReportType] [int] NOT NULL,
    [ReportDataType] [int] NOT NULL,
    [ReportFilename] [nvarchar](250),
    [SBStatus] [int] NOT NULL,
    [Key] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.VerificationReports] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[VerificationReviewers] (
    [ID] [bigint] NOT NULL IDENTITY,
    [ReviewerName] [nvarchar](max),
    CONSTRAINT [PK_dbo.VerificationReviewers] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[VerificationTuners] (
    [ID] [bigint] NOT NULL IDENTITY,
    [TunerName] [nvarchar](max),
    CONSTRAINT [PK_dbo.VerificationTuners] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[VideoConversions] (
    [ID] [bigint] NOT NULL IDENTITY,
    [UploadedDateTime] [datetime] NOT NULL,
    [FileName] [nvarchar](max),
    [Converted] [bit] NOT NULL,
    CONSTRAINT [PK_dbo.VideoConversions] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[VirtualReceptionRoles] (
    [Id] [bigint] NOT NULL IDENTITY,
    [UserId] [bigint] NOT NULL,
    [VisitationPurposeId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.VirtualReceptionRoles] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[VisitorCapacities] (
    [ID] [bigint] NOT NULL IDENTITY,
    [TypeID] [bigint] NOT NULL,
    [Type] [int] NOT NULL,
    [Capacity] [int] NOT NULL,
    [LiveThreshold1] [int] NOT NULL,
    [LiveThreshold2] [int] NOT NULL,
    [CreatedTimestamp] [bigint] NOT NULL,
    [UpdatedTimestamp] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.VisitorCapacities] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[WidgetInstances] (
    [Id] [bigint] NOT NULL IDENTITY,
    [TemplateId] [bigint] NOT NULL,
    [Name] [nvarchar](max),
    [Configuration] [nvarchar](max),
    [WidgetType] [int] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [Parameters] [nvarchar](max),
    CONSTRAINT [PK_dbo.WidgetInstances] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[WidgetMetricSets] (
    [ID] [bigint] NOT NULL IDENTITY,
    [FunctionName] [nvarchar](max),
    [CustomDashboardWidgetID] [bigint] NOT NULL,
    [MetricID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.WidgetMetricSets] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[WidgetSsiTemplates] (
    [SsiTemplateId] [bigint] NOT NULL IDENTITY,
    [CompanyId] [bigint] NOT NULL,
    [SsiTemplateContent] [nvarchar](max),
    [CreatedDateTime] [datetime] NOT NULL,
    [UpdateDateTime] [datetime],
    [WidgetType] [nvarchar](max),
    [SsiTemplateName] [nvarchar](max),
    CONSTRAINT [PK_dbo.WidgetSsiTemplates] PRIMARY KEY ([SsiTemplateId])
)
CREATE TABLE [dbo].[WorkspaceAttendees] (
    [Id] [uniqueidentifier] NOT NULL DEFAULT newsequentialid(),
    [UserId] [bigint] NOT NULL,
    [IsHost] [bit] NOT NULL,
    [WorkspaceUserType] [int] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime] NOT NULL,
    [BookingId] [uniqueidentifier] NOT NULL,
    CONSTRAINT [PK_dbo.WorkspaceAttendees] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[WorkspaceGuests] (
    [Id] [bigint] NOT NULL IDENTITY,
    [Name] [nvarchar](max),
    [Email] [nvarchar](max),
    [ServerGuid] [uniqueidentifier] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    [CreatedBy] [bigint] NOT NULL,
    [CreatedDateTime] [datetime] NOT NULL,
    [IsDeleted] [bit] NOT NULL,
    [DeletedDateTime] [datetime] NOT NULL,
    CONSTRAINT [PK_dbo.WorkspaceGuests] PRIMARY KEY ([Id])
)
CREATE TABLE [dbo].[WorkWeekConfigurations] (
    [ID] [bigint] NOT NULL IDENTITY,
    [DayOfWeek] [int] NOT NULL,
    [IsWeekday] [bit] NOT NULL,
    [CompanyId] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.WorkWeekConfigurations] PRIMARY KEY ([ID])
)
CREATE TABLE [dbo].[FFAreaSankeyFFAreaProfileDetails] (
    [FFAreaSankey_Id] [bigint] NOT NULL,
    [FFAreaProfileDetail_Id] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFAreaSankeyFFAreaProfileDetails] PRIMARY KEY ([FFAreaSankey_Id], [FFAreaProfileDetail_Id])
)
CREATE TABLE [dbo].[UserGroupsScheduledNotifications] (
    [UserGroups_ID] [bigint] NOT NULL,
    [ScheduledNotifications_ID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.UserGroupsScheduledNotifications] PRIMARY KEY ([UserGroups_ID], [ScheduledNotifications_ID])
)
CREATE TABLE [dbo].[FFCorridorFFCameras] (
    [FFCorridor_Id] [bigint] NOT NULL,
    [FFCamera_ID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.FFCorridorFFCameras] PRIMARY KEY ([FFCorridor_Id], [FFCamera_ID])
)
CREATE TABLE [dbo].[NotificationTriggersFFCameras] (
    [NotificationTrigger_Id] [bigint] NOT NULL,
    [FFCamera_ID] [bigint] NOT NULL,
    CONSTRAINT [PK_dbo.NotificationTriggersFFCameras] PRIMARY KEY ([NotificationTrigger_Id], [FFCamera_ID])
)
CREATE INDEX [IX_ReportID] ON [dbo].[AccuracyReportLists]([ReportID])
CREATE INDEX [IX_FFCameraId] ON [dbo].[FFVerificationStudyReports]([FFCameraId])
CREATE UNIQUE INDEX [IX_Serial] ON [dbo].[FFCameras]([Serial])
CREATE INDEX [IX_UserId] ON [dbo].[FFCameras]([UserId])
CREATE INDEX [IX_NewZoneId] ON [dbo].[FFCameras]([NewZoneId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraCountingValues]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraHourlyValues]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[CameraLineSettings]([CameraId])
CREATE INDEX [IX_CameraLineId] ON [dbo].[AreaConfigurationSettings]([CameraLineId])
CREATE INDEX [IX_AreaId] ON [dbo].[AreaConfigurationSettings]([AreaId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFAreas]([BranchId])
CREATE INDEX [IX_ParentAreaId] ON [dbo].[FFAreas]([ParentAreaId])
CREATE INDEX [IX_AreaId] ON [dbo].[AreaAppPermissions]([AreaId])
CREATE UNIQUE INDEX [IX_AreaDateDaily] ON [dbo].[FFAreaDailies]([AreaId], [Date])
CREATE UNIQUE INDEX [IX_AreaDateHourly] ON [dbo].[FFAreaHourlies]([AreaId], [ValueDateTime])
CREATE INDEX [IX_SiteId] ON [dbo].[BookingSchedules]([SiteId])
CREATE INDEX [IX_LocationId] ON [dbo].[BookingSchedules]([LocationId])
CREATE INDEX [IX_AreaId] ON [dbo].[BookingSchedules]([AreaId])
CREATE INDEX [IX_CompanyId] ON [dbo].[FFBranches]([CompanyId])
CREATE INDEX [IX_UserId] ON [dbo].[FFBranches]([UserId])
CREATE INDEX [IX_RegionId] ON [dbo].[FFBranches]([RegionId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFAreaProfiles]([BranchId])
CREATE INDEX [IX_AreaProfileId] ON [dbo].[FFAreaProfileDetails]([AreaProfileId])
CREATE INDEX [IX_FromAreaId] ON [dbo].[FFAreaSankeys]([FromAreaId])
CREATE INDEX [IX_ToAreaId] ON [dbo].[FFAreaSankeys]([ToAreaId])
CREATE UNIQUE INDEX [IX_BranchCrossShopDate] ON [dbo].[FFBranchCrossShops]([ValueDateTime], [ToBranch], [FromBranch])
CREATE INDEX [IX_BranchID] ON [dbo].[BranchWorkspaceDetails]([BranchID])
CREATE INDEX [IX_PeriodID] ON [dbo].[BranchWorkspaceDetails]([PeriodID])
CREATE INDEX [IX_CompanyID] ON [dbo].[WorkspacePeriods]([CompanyID])
CREATE INDEX [IX_UserId] ON [dbo].[Companies]([UserId])
CREATE INDEX [IX_CompanyId] ON [dbo].[CompanyCards]([CompanyId])
CREATE INDEX [IX_Type_ID] ON [dbo].[FFDataSettings]([Type_ID])
CREATE INDEX [IX_Company_ID] ON [dbo].[FFDataSettings]([Company_ID])
CREATE INDEX [IX_CompanyID] ON [dbo].[Locations]([CompanyID])
CREATE INDEX [IX_LocationId] ON [dbo].[LocationAreaLinks]([LocationId])
CREATE INDEX [IX_AreaId] ON [dbo].[LocationAreaLinks]([AreaId])
CREATE INDEX [IX_CompanyID] ON [dbo].[MetricDefinitions]([CompanyID])
CREATE INDEX [IX_MetricDefinitionID] ON [dbo].[MetricThresholdConfigurations]([MetricDefinitionID])
CREATE INDEX [IX_CompanyId] ON [dbo].[PublicHolidayConfigurations]([CompanyId])
CREATE INDEX [IX_PublicHolidayId] ON [dbo].[PublicHolidayLinks]([PublicHolidayId])
CREATE INDEX [IX_notificationCat] ON [dbo].[ScheduledNotifications]([notificationCat])
CREATE INDEX [IX_companyID] ON [dbo].[ScheduledNotifications]([companyID])
CREATE INDEX [IX_scheduledEmailID] ON [dbo].[scheduledSingleMails]([scheduledEmailID])
CREATE INDEX [IX_scheduledNotificationsID] ON [dbo].[scheduledSingleMails]([scheduledNotificationsID])
CREATE INDEX [IX_ScheduledEmailID] ON [dbo].[generateEmailLogs]([ScheduledEmailID])
CREATE INDEX [IX_ScheduledEmailID] ON [dbo].[sendEmailLogs]([ScheduledEmailID])
CREATE INDEX [IX_UserGroupID] ON [dbo].[userGroupsEmails]([UserGroupID])
CREATE INDEX [IX_UserID] ON [dbo].[userGroupsEmails]([UserID])
CREATE INDEX [IX_UserId] ON [dbo].[EslCustomFields]([UserId])
CREATE INDEX [IX_EslCustomFieldId] ON [dbo].[EslCustomFieldTemplateLinks]([EslCustomFieldId])
CREATE INDEX [IX_EslTemplateId] ON [dbo].[EslCustomFieldTemplateLinks]([EslTemplateId])
CREATE INDEX [IX_UserId] ON [dbo].[ESLTemplates]([UserId])
CREATE INDEX [IX_UserId] ON [dbo].[FFUserAccesses]([UserId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFUserAccesses]([BranchId])
CREATE INDEX [IX_UserID] ON [dbo].[UserBookmarkedReports]([UserID])
CREATE INDEX [IX_ReportID] ON [dbo].[UserBookmarkedReports]([ReportID])
CREATE INDEX [IX_ReportFolderID] ON [dbo].[CustomReports]([ReportFolderID])
CREATE INDEX [IX_CreatorUserID] ON [dbo].[CustomReports]([CreatorUserID])
CREATE INDEX [IX_CustomReportId] ON [dbo].[CustomReportAccesses]([CustomReportId])
CREATE INDEX [IX_BranchId] ON [dbo].[CustomReportAccesses]([BranchId])
CREATE INDEX [IX_CompanyID] ON [dbo].[ReportFolders]([CompanyID])
CREATE INDEX [IX_CompanyId] ON [dbo].[CompanySettings]([CompanyId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFCorridors]([BranchId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFBranchDailyPredictions]([BranchId])
CREATE INDEX [IX_BranchDailyPredictionId] ON [dbo].[FFDailyPredictions]([BranchDailyPredictionId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFZoneSankeyDailies]([BranchId])
CREATE INDEX [IX_ZoneIdA] ON [dbo].[FFZoneSankeyDailies]([ZoneIdA])
CREATE INDEX [IX_ZoneIdB] ON [dbo].[FFZoneSankeyDailies]([ZoneIdB])
CREATE INDEX [IX_BranchId] ON [dbo].[FFZones]([BranchId])
CREATE INDEX [IX_BranchFloorId] ON [dbo].[FFZones]([BranchFloorId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFBranchFloors]([BranchId])
CREATE INDEX [IX_FFBranchFloor_ID] ON [dbo].[FFCameraZones]([FFBranchFloor_ID])
CREATE UNIQUE INDEX [IX_ZoneAndDate] ON [dbo].[FFZoneDailies]([ValueDateTime], [ZoneID])
CREATE UNIQUE INDEX [IX_ZoneAndHour] ON [dbo].[FFZoneHourlies]([ValueDateTime], [ZoneID])
CREATE UNIQUE INDEX [IX_Serial] ON [dbo].[EslTags]([Serial])
CREATE INDEX [IX_ESLTemplateId] ON [dbo].[EslTags]([ESLTemplateId])
CREATE INDEX [IX_BranchId] ON [dbo].[EslTags]([BranchId])
CREATE INDEX [IX_ProductId] ON [dbo].[EslTags]([ProductId])
CREATE INDEX [IX_CompanyId] ON [dbo].[Products]([CompanyId])
CREATE INDEX [IX_ProductCategoryId] ON [dbo].[Products]([ProductCategoryId])
CREATE INDEX [IX_ProductBrandId] ON [dbo].[Products]([ProductBrandId])
CREATE INDEX [IX_CompanyId] ON [dbo].[ProductBrands]([CompanyId])
CREATE INDEX [IX_CompanyId] ON [dbo].[ProductCategories]([CompanyId])
CREATE INDEX [IX_ProductId] ON [dbo].[ProductDailySales]([ProductId])
CREATE INDEX [IX_BranchId] ON [dbo].[ProductDailySales]([BranchId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFBranchOperatingHours]([BranchId])
CREATE INDEX [IX_CompanyId] ON [dbo].[FFRegions]([CompanyId])
CREATE INDEX [IX_SiteGroupId] ON [dbo].[SiteGroupLinks]([SiteGroupId])
CREATE INDEX [IX_BranchId] ON [dbo].[SiteGroupLinks]([BranchId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFBranchSpecialOperatingHours]([BranchId])
CREATE INDEX [IX_BranchId] ON [dbo].[SiteVehicleLinks]([BranchId])
CREATE INDEX [IX_BranchId] ON [dbo].[VirtualReceptionVisitationPurposes]([BranchId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraOperatingHours]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraSettings]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraSettingBackUps]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraSimulatorSettings]([CameraId])
CREATE INDEX [IX_NotificationSettingsId] ON [dbo].[NotificationTriggers]([NotificationSettingsId])
CREATE INDEX [IX_FFVideoScheduleId] ON [dbo].[FFVerificationStudyReportVideos]([FFVideoScheduleId])
CREATE INDEX [IX_FFVerificationStudyReportId] ON [dbo].[FFVerificationStudyReportVideos]([FFVerificationStudyReportId])
CREATE INDEX [IX_FFCameraId] ON [dbo].[FFVideoSchedules]([FFCameraId])
CREATE INDEX [IX_VideoScheduleId] ON [dbo].[VideoSchedules]([VideoScheduleId])
CREATE INDEX [IX_VideoScheduleId] ON [dbo].[VideoScheduleDatas]([VideoScheduleId])
CREATE INDEX [IX_RuleId] ON [dbo].[NotificationAlerts]([RuleId])
CREATE INDEX [IX_MessageTemplateId] ON [dbo].[NotificationAlerts]([MessageTemplateId])
CREATE INDEX [IX_CompanyId] ON [dbo].[MessageTemplates]([CompanyId])
CREATE INDEX [IX_NotificationId] ON [dbo].[NotificationRecipients]([NotificationId])
CREATE INDEX [IX_UserGroupId] ON [dbo].[NotificationRecipients]([UserGroupId])
CREATE INDEX [IX_RuleID] ON [dbo].[RuleTriggerConditions]([RuleID])
CREATE INDEX [IX_RuleTriggerConditionID] ON [dbo].[RuleActions]([RuleTriggerConditionID])
CREATE INDEX [IX_AlertRuleId] ON [dbo].[ThresholdMetricRules]([AlertRuleId])
CREATE INDEX [IX_FFVideoScheduleId] ON [dbo].[ApiActions]([FFVideoScheduleId])
CREATE INDEX [IX_FloorplanID] ON [dbo].[AreaPlots]([FloorplanID])
CREATE INDEX [IX_FloorplanID] ON [dbo].[DevicePlots]([FloorplanID])
CREATE INDEX [IX_AreaId] ON [dbo].[AreaSpaceAmenities]([AreaId])
CREATE INDEX [IX_AreaId] ON [dbo].[AreaSpaceConfigurations]([AreaId])
CREATE INDEX [IX_AreaId] ON [dbo].[AreaSpaceImages]([AreaId])
CREATE INDEX [IX_BusTripId] ON [dbo].[Bus_BusTripLink]([BusTripId])
CREATE INDEX [IX_BusRouteId] ON [dbo].[BusTrips]([BusRouteId])
CREATE INDEX [IX_CompanyId] ON [dbo].[BusRoutes]([CompanyId])
CREATE INDEX [IX_BusRouteId] ON [dbo].[BusTicketSalesDatas]([BusRouteId])
CREATE INDEX [IX_BusTripId] ON [dbo].[BusTicketSalesDatas]([BusTripId])
CREATE INDEX [IX_BusStationId] ON [dbo].[BusTicketSalesDatas]([BusStationId])
CREATE INDEX [IX_BusDetailId] ON [dbo].[BusTicketSalesDatas]([BusDetailId])
CREATE INDEX [IX_CompanyId] ON [dbo].[BusStations]([CompanyId])
CREATE INDEX [IX_BusTripId] ON [dbo].[BusTripStationLinks]([BusTripId])
CREATE INDEX [IX_BusStationId] ON [dbo].[BusTripStationLinks]([BusStationId])
CREATE INDEX [IX_CompanyId] ON [dbo].[CompanyBusPostProcesses]([CompanyId])
CREATE INDEX [IX_CompanyId] ON [dbo].[CompanyBusPostProcessLogs]([CompanyId])
CREATE INDEX [IX_CompanyId] ON [dbo].[CompanyCounterSettings]([CompanyId])
CREATE INDEX [IX_EslId] ON [dbo].[EslAreaSpaceLinks]([EslId])
CREATE INDEX [IX_AreaId] ON [dbo].[EslAreaSpaceLinks]([AreaId])
CREATE UNIQUE INDEX [IX_EslTagSerial] ON [dbo].[ESLCounterDbms]([EslTagSerial])
CREATE INDEX [IX_EslCustomFieldId] ON [dbo].[EslCustomFieldValues]([EslCustomFieldId])
CREATE UNIQUE INDEX [IX_Unique_AreaDate] ON [dbo].[FFAreaMinuteCarOccupancyValues]([AreaId], [ValueDateTime])
CREATE UNIQUE INDEX [IX_Unique_AreaDate] ON [dbo].[FFAreaMinuteOccupancyValues]([AreaId], [ValueDateTime])
CREATE UNIQUE INDEX [IX_Unique_AreaDate] ON [dbo].[FFAreaMinuteStaffOccupancyValues]([AreaId], [ValueDateTime])
CREATE INDEX [IX_BranchId] ON [dbo].[FFBranch15MinuteValue]([BranchId])
CREATE UNIQUE INDEX [IX_Unique_BranchDate] ON [dbo].[FFBranchHourlyMaxStaffOccupancyValues]([BranchId], [ValueDateTime])
CREATE UNIQUE INDEX [IX_Unique_BranchDate] ON [dbo].[FFBranchHourlyStaffOccupancyValues]([BranchId], [ValueDateTime])
CREATE UNIQUE INDEX [IX_Unique_BranchDate] ON [dbo].[FFBranchMinuteCarOccupancyValues]([BranchId], [ValueDateTime])
CREATE UNIQUE INDEX [IX_Unique_BranchDate] ON [dbo].[FFBranchMinuteOccupancyValues]([BranchId], [ValueDateTime])
CREATE UNIQUE INDEX [IX_Unique_BranchDate] ON [dbo].[FFBranchMinuteStaffOccupancyValues]([BranchId], [ValueDateTime])
CREATE UNIQUE INDEX [IX_BranchDate] ON [dbo].[FFBranchSummaryDailyReports]([Date], [BranchId])
CREATE UNIQUE INDEX [IX_Unique_VDT_BranchId] ON [dbo].[FFBranchSummaryHourlyReports]([ValueDateTime], [BranchId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFBranchDailyTargets]([BranchId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCamera15MinuteValue]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraCountingRecords]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraCustomerValues]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraCustomerValueArchives]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraHeatValues]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraMinuteValues]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraValues]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraWifiThresValues]([CameraId])
CREATE INDEX [IX_CameraId] ON [dbo].[FFCameraWifiValues]([CameraId])
CREATE INDEX [IX_FFCommissionId] ON [dbo].[FFCommissionImages]([FFCommissionId])
CREATE INDEX [IX_BranchId] ON [dbo].[FFCrossShoppers]([BranchId])
CREATE INDEX [IX_ReportId] ON [dbo].[FFEmailReports]([ReportId])
CREATE UNIQUE INDEX [IX_Unique_Camera_Date] ON [dbo].[FFReportSummaryDailies]([Date], [CameraId])
CREATE INDEX [IX_FFVideoScheduleId] ON [dbo].[FFVideoScheduleLogRemarks]([FFVideoScheduleId])
CREATE INDEX [IX_FirmwareID] ON [dbo].[FirmwareStages]([FirmwareID])
CREATE INDEX [IX_ReportFolderID] ON [dbo].[FolderSubscribers]([ReportFolderID])
CREATE INDEX [IX_UserID] ON [dbo].[FolderSubscribers]([UserID])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsAgencies]([company_id])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsCalendars]([company_id])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsCalendarDates]([company_id])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsRoutes]([company_id])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsShapes]([company_id])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsStops]([company_id])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsStopTimes]([company_id])
CREATE INDEX [IX_company_id] ON [dbo].[GtfsTrips]([company_id])
CREATE INDEX [IX_CompanyId] ON [dbo].[HotspotEmails]([CompanyId])
CREATE INDEX [IX_CompanyId] ON [dbo].[HotspotSettings]([CompanyId])
CREATE INDEX [IX_JetsonID] ON [dbo].[JetsonCCTVs]([JetsonID])
CREATE INDEX [IX_CCTVID] ON [dbo].[JetsonQueueCountings]([CCTVID])
CREATE INDEX [IX_LinkShortenerId] ON [dbo].[LinkShortenerLinkages]([LinkShortenerId])
CREATE INDEX [IX_CompanyId] ON [dbo].[MagicMirrorCompanyLinks]([CompanyId])
CREATE INDEX [IX_MarketingCampaignId] ON [dbo].[MarketingCampaignPeriods]([MarketingCampaignId])
CREATE INDEX [IX_MarketingCampaignId] ON [dbo].[MarketingCampaignRecurringDays]([MarketingCampaignId])
CREATE INDEX [IX_MarketingCampaignId] ON [dbo].[MarketingCampaignSites]([MarketingCampaignId])
CREATE INDEX [IX_BranchId] ON [dbo].[MarketingCampaignSites]([BranchId])
CREATE INDEX [IX_companyID] ON [dbo].[MarketingTrackerReports]([companyID])
CREATE INDEX [IX_MarketingTrackerReportID] ON [dbo].[MarketingTrackerReportSiteLists]([MarketingTrackerReportID])
CREATE UNIQUE INDEX [IX_Unique_typeDate] ON [dbo].[MinuteOccupancyValues]([MetricCode], [Type], [TypeId], [ValueDateTime])
CREATE INDEX [IX_NotificationMessageId] ON [dbo].[NotificationEventLogs]([NotificationMessageId])
CREATE INDEX [IX_branchid] ON [dbo].[NotificationGateways]([branchid])
CREATE INDEX [IX_cameraid] ON [dbo].[NotificationGatewayThresholds]([cameraid])
CREATE INDEX [IX_NotificationTriggersId] ON [dbo].[NotificationTypes]([NotificationTriggersId])
CREATE INDEX [IX_NotificationMessageId] ON [dbo].[NotificationUserLinks]([NotificationMessageId])
CREATE INDEX [IX_UserId] ON [dbo].[NotificationUserLinks]([UserId])
CREATE INDEX [IX_UserId] ON [dbo].[FFPageAccesses]([UserId])
CREATE INDEX [IX_CompanyId] ON [dbo].[FFPageAccessCompanies]([CompanyId])
CREATE UNIQUE INDEX [IX_pageID] ON [dbo].[Pages]([pageID])
CREATE INDEX [IX_PatchID] ON [dbo].[PatchStages]([PatchID])
CREATE INDEX [IX_ProductId] ON [dbo].[ProductCurrencyPrices]([ProductId])
CREATE INDEX [IX_ProductId] ON [dbo].[ProductCustomPrices]([ProductId])
CREATE INDEX [IX_CameraId] ON [dbo].[QueueUsageSettings]([CameraId])
CREATE INDEX [IX_CustomReportID] ON [dbo].[ReportSubscribers]([CustomReportID])
CREATE INDEX [IX_RuleId] ON [dbo].[RuleEngineActions]([RuleId])
CREATE INDEX [IX_CompanyId] ON [dbo].[ServiceSubscriptions]([CompanyId])
CREATE INDEX [IX_BranchId] ON [dbo].[SiteNotesForCustomers]([BranchId])
CREATE INDEX [IX_BranchId] ON [dbo].[SitePendingIssues]([BranchId])
CREATE INDEX [IX_StandardizedLoginStatusId] ON [dbo].[StandardizedLoginAttemptLogs]([StandardizedLoginStatusId])
CREATE INDEX [IX_CompanyId] ON [dbo].[UserDefinedImportFileHeaderMappings]([CompanyId])
CREATE INDEX [IX_CompanyId] ON [dbo].[ConfigurationUserGroups]([CompanyId])
CREATE INDEX [IX_ConfigurationUserGroupId] ON [dbo].[UserGroupSettings]([ConfigurationUserGroupId])
CREATE INDEX [IX_UserId] ON [dbo].[UserGroupLinks]([UserId])
CREATE INDEX [IX_ConfigurationUserGroupId] ON [dbo].[UserGroupLinks]([ConfigurationUserGroupId])
CREATE INDEX [IX_UserId] ON [dbo].[UserSiteGroupLinks]([UserId])
CREATE INDEX [IX_SiteGroupId] ON [dbo].[UserSiteGroupLinks]([SiteGroupId])
CREATE INDEX [IX_UserId] ON [dbo].[VirtualReceptionRoles]([UserId])
CREATE INDEX [IX_VisitationPurposeId] ON [dbo].[VirtualReceptionRoles]([VisitationPurposeId])
CREATE INDEX [IX_CustomDashboardWidgetID] ON [dbo].[WidgetMetricSets]([CustomDashboardWidgetID])
CREATE INDEX [IX_CompanyId] ON [dbo].[WidgetSsiTemplates]([CompanyId])
CREATE INDEX [IX_BookingId] ON [dbo].[WorkspaceAttendees]([BookingId])
CREATE INDEX [IX_CompanyId] ON [dbo].[WorkWeekConfigurations]([CompanyId])
CREATE INDEX [IX_FFAreaSankey_Id] ON [dbo].[FFAreaSankeyFFAreaProfileDetails]([FFAreaSankey_Id])
CREATE INDEX [IX_FFAreaProfileDetail_Id] ON [dbo].[FFAreaSankeyFFAreaProfileDetails]([FFAreaProfileDetail_Id])
CREATE INDEX [IX_UserGroups_ID] ON [dbo].[UserGroupsScheduledNotifications]([UserGroups_ID])
CREATE INDEX [IX_ScheduledNotifications_ID] ON [dbo].[UserGroupsScheduledNotifications]([ScheduledNotifications_ID])
CREATE INDEX [IX_FFCorridor_Id] ON [dbo].[FFCorridorFFCameras]([FFCorridor_Id])
CREATE INDEX [IX_FFCamera_ID] ON [dbo].[FFCorridorFFCameras]([FFCamera_ID])
CREATE INDEX [IX_NotificationTrigger_Id] ON [dbo].[NotificationTriggersFFCameras]([NotificationTrigger_Id])
CREATE INDEX [IX_FFCamera_ID] ON [dbo].[NotificationTriggersFFCameras]([FFCamera_ID])
ALTER TABLE [dbo].[AccuracyReportLists] ADD CONSTRAINT [FK_dbo.AccuracyReportLists_dbo.FFVerificationStudyReports_ReportID] FOREIGN KEY ([ReportID]) REFERENCES [dbo].[FFVerificationStudyReports] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFVerificationStudyReports] ADD CONSTRAINT [FK_dbo.FFVerificationStudyReports_dbo.FFCameras_FFCameraId] FOREIGN KEY ([FFCameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameras] ADD CONSTRAINT [FK_dbo.FFCameras_dbo.FFZones_NewZoneId] FOREIGN KEY ([NewZoneId]) REFERENCES [dbo].[FFZones] ([ID])
ALTER TABLE [dbo].[FFCameras] ADD CONSTRAINT [FK_dbo.FFCameras_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[FFCameraCountingValues] ADD CONSTRAINT [FK_dbo.FFCameraCountingValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID])
ALTER TABLE [dbo].[FFCameraHourlyValues] ADD CONSTRAINT [FK_dbo.FFCameraHourlyValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[CameraLineSettings] ADD CONSTRAINT [FK_dbo.CameraLineSettings_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[AreaConfigurationSettings] ADD CONSTRAINT [FK_dbo.AreaConfigurationSettings_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[AreaConfigurationSettings] ADD CONSTRAINT [FK_dbo.AreaConfigurationSettings_dbo.CameraLineSettings_CameraLineId] FOREIGN KEY ([CameraLineId]) REFERENCES [dbo].[CameraLineSettings] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreas] ADD CONSTRAINT [FK_dbo.FFAreas_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreas] ADD CONSTRAINT [FK_dbo.FFAreas_dbo.FFAreas_ParentAreaId] FOREIGN KEY ([ParentAreaId]) REFERENCES [dbo].[FFAreas] ([Id])
ALTER TABLE [dbo].[AreaAppPermissions] ADD CONSTRAINT [FK_dbo.AreaAppPermissions_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id])
ALTER TABLE [dbo].[FFAreaDailies] ADD CONSTRAINT [FK_dbo.FFAreaDailies_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreaHourlies] ADD CONSTRAINT [FK_dbo.FFAreaHourlies_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[BookingSchedules] ADD CONSTRAINT [FK_dbo.BookingSchedules_dbo.FFBranches_SiteId] FOREIGN KEY ([SiteId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[BookingSchedules] ADD CONSTRAINT [FK_dbo.BookingSchedules_dbo.Locations_LocationId] FOREIGN KEY ([LocationId]) REFERENCES [dbo].[Locations] ([ID])
ALTER TABLE [dbo].[BookingSchedules] ADD CONSTRAINT [FK_dbo.BookingSchedules_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id])
ALTER TABLE [dbo].[FFBranches] ADD CONSTRAINT [FK_dbo.FFBranches_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFBranches] ADD CONSTRAINT [FK_dbo.FFBranches_dbo.FFRegions_RegionId] FOREIGN KEY ([RegionId]) REFERENCES [dbo].[FFRegions] ([ID])
ALTER TABLE [dbo].[FFBranches] ADD CONSTRAINT [FK_dbo.FFBranches_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreaProfiles] ADD CONSTRAINT [FK_dbo.FFAreaProfiles_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreaProfileDetails] ADD CONSTRAINT [FK_dbo.FFAreaProfileDetails_dbo.FFAreaProfiles_AreaProfileId] FOREIGN KEY ([AreaProfileId]) REFERENCES [dbo].[FFAreaProfiles] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreaSankeys] ADD CONSTRAINT [FK_dbo.FFAreaSankeys_dbo.FFAreas_FromAreaId] FOREIGN KEY ([FromAreaId]) REFERENCES [dbo].[FFAreas] ([Id])
ALTER TABLE [dbo].[FFAreaSankeys] ADD CONSTRAINT [FK_dbo.FFAreaSankeys_dbo.FFAreas_ToAreaId] FOREIGN KEY ([ToAreaId]) REFERENCES [dbo].[FFAreas] ([Id])
ALTER TABLE [dbo].[FFBranchCrossShops] ADD CONSTRAINT [FK_dbo.FFBranchCrossShops_dbo.FFBranches_ToBranch] FOREIGN KEY ([ToBranch]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[FFBranchCrossShops] ADD CONSTRAINT [FK_dbo.FFBranchCrossShops_dbo.FFBranches_FromBranch] FOREIGN KEY ([FromBranch]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[BranchWorkspaceDetails] ADD CONSTRAINT [FK_dbo.BranchWorkspaceDetails_dbo.FFBranches_BranchID] FOREIGN KEY ([BranchID]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[BranchWorkspaceDetails] ADD CONSTRAINT [FK_dbo.BranchWorkspaceDetails_dbo.WorkspacePeriods_PeriodID] FOREIGN KEY ([PeriodID]) REFERENCES [dbo].[WorkspacePeriods] ([ID])
ALTER TABLE [dbo].[WorkspacePeriods] ADD CONSTRAINT [FK_dbo.WorkspacePeriods_dbo.Companies_CompanyID] FOREIGN KEY ([CompanyID]) REFERENCES [dbo].[Companies] ([ID])
ALTER TABLE [dbo].[Companies] ADD CONSTRAINT [FK_dbo.Companies_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[CompanyCards] ADD CONSTRAINT [FK_dbo.CompanyCards_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFDataSettings] ADD CONSTRAINT [FK_dbo.FFDataSettings_dbo.DataSettingTypes_Type_ID] FOREIGN KEY ([Type_ID]) REFERENCES [dbo].[DataSettingTypes] ([ID])
ALTER TABLE [dbo].[FFDataSettings] ADD CONSTRAINT [FK_dbo.FFDataSettings_dbo.Companies_Company_ID] FOREIGN KEY ([Company_ID]) REFERENCES [dbo].[Companies] ([ID])
ALTER TABLE [dbo].[Locations] ADD CONSTRAINT [FK_dbo.Locations_dbo.Companies_CompanyID] FOREIGN KEY ([CompanyID]) REFERENCES [dbo].[Companies] ([ID])
ALTER TABLE [dbo].[LocationAreaLinks] ADD CONSTRAINT [FK_dbo.LocationAreaLinks_dbo.Locations_LocationId] FOREIGN KEY ([LocationId]) REFERENCES [dbo].[Locations] ([ID])
ALTER TABLE [dbo].[LocationAreaLinks] ADD CONSTRAINT [FK_dbo.LocationAreaLinks_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id])
ALTER TABLE [dbo].[MetricDefinitions] ADD CONSTRAINT [FK_dbo.MetricDefinitions_dbo.Companies_CompanyID] FOREIGN KEY ([CompanyID]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[MetricThresholdConfigurations] ADD CONSTRAINT [FK_dbo.MetricThresholdConfigurations_dbo.MetricDefinitions_MetricDefinitionID] FOREIGN KEY ([MetricDefinitionID]) REFERENCES [dbo].[MetricDefinitions] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[PublicHolidayConfigurations] ADD CONSTRAINT [FK_dbo.PublicHolidayConfigurations_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID])
ALTER TABLE [dbo].[PublicHolidayLinks] ADD CONSTRAINT [FK_dbo.PublicHolidayLinks_dbo.PublicHolidayConfigurations_PublicHolidayId] FOREIGN KEY ([PublicHolidayId]) REFERENCES [dbo].[PublicHolidayConfigurations] ([Id])
ALTER TABLE [dbo].[ScheduledNotifications] ADD CONSTRAINT [FK_dbo.ScheduledNotifications_dbo.notificationModules_notificationCat] FOREIGN KEY ([notificationCat]) REFERENCES [dbo].[notificationModules] ([ID])
ALTER TABLE [dbo].[ScheduledNotifications] ADD CONSTRAINT [FK_dbo.ScheduledNotifications_dbo.Companies_companyID] FOREIGN KEY ([companyID]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[scheduledSingleMails] ADD CONSTRAINT [FK_dbo.scheduledSingleMails_dbo.ScheduledEmails_scheduledEmailID] FOREIGN KEY ([scheduledEmailID]) REFERENCES [dbo].[ScheduledEmails] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[scheduledSingleMails] ADD CONSTRAINT [FK_dbo.scheduledSingleMails_dbo.ScheduledNotifications_scheduledNotificationsID] FOREIGN KEY ([scheduledNotificationsID]) REFERENCES [dbo].[ScheduledNotifications] ([ID])
ALTER TABLE [dbo].[generateEmailLogs] ADD CONSTRAINT [FK_dbo.generateEmailLogs_dbo.ScheduledEmails_ScheduledEmailID] FOREIGN KEY ([ScheduledEmailID]) REFERENCES [dbo].[ScheduledEmails] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[sendEmailLogs] ADD CONSTRAINT [FK_dbo.sendEmailLogs_dbo.ScheduledEmails_ScheduledEmailID] FOREIGN KEY ([ScheduledEmailID]) REFERENCES [dbo].[ScheduledEmails] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[userGroupsEmails] ADD CONSTRAINT [FK_dbo.userGroupsEmails_dbo.Users_UserID] FOREIGN KEY ([UserID]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[userGroupsEmails] ADD CONSTRAINT [FK_dbo.userGroupsEmails_dbo.UserGroups_UserGroupID] FOREIGN KEY ([UserGroupID]) REFERENCES [dbo].[UserGroups] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[EslCustomFields] ADD CONSTRAINT [FK_dbo.EslCustomFields_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[EslCustomFieldTemplateLinks] ADD CONSTRAINT [FK_dbo.EslCustomFieldTemplateLinks_dbo.EslCustomFields_EslCustomFieldId] FOREIGN KEY ([EslCustomFieldId]) REFERENCES [dbo].[EslCustomFields] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[EslCustomFieldTemplateLinks] ADD CONSTRAINT [FK_dbo.EslCustomFieldTemplateLinks_dbo.ESLTemplates_EslTemplateId] FOREIGN KEY ([EslTemplateId]) REFERENCES [dbo].[ESLTemplates] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[ESLTemplates] ADD CONSTRAINT [FK_dbo.ESLTemplates_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[FFUserAccesses] ADD CONSTRAINT [FK_dbo.FFUserAccesses_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[FFUserAccesses] ADD CONSTRAINT [FK_dbo.FFUserAccesses_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[UserBookmarkedReports] ADD CONSTRAINT [FK_dbo.UserBookmarkedReports_dbo.CustomReports_ReportID] FOREIGN KEY ([ReportID]) REFERENCES [dbo].[CustomReports] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserBookmarkedReports] ADD CONSTRAINT [FK_dbo.UserBookmarkedReports_dbo.Users_UserID] FOREIGN KEY ([UserID]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[CustomReports] ADD CONSTRAINT [FK_dbo.CustomReports_dbo.ReportFolders_ReportFolderID] FOREIGN KEY ([ReportFolderID]) REFERENCES [dbo].[ReportFolders] ([ID])
ALTER TABLE [dbo].[CustomReports] ADD CONSTRAINT [FK_dbo.CustomReports_dbo.Users_CreatorUserID] FOREIGN KEY ([CreatorUserID]) REFERENCES [dbo].[Users] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[CustomReportAccesses] ADD CONSTRAINT [FK_dbo.CustomReportAccesses_dbo.CustomReports_CustomReportId] FOREIGN KEY ([CustomReportId]) REFERENCES [dbo].[CustomReports] ([ID])
ALTER TABLE [dbo].[CustomReportAccesses] ADD CONSTRAINT [FK_dbo.CustomReportAccesses_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[ReportFolders] ADD CONSTRAINT [FK_dbo.ReportFolders_dbo.Companies_CompanyID] FOREIGN KEY ([CompanyID]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[CompanySettings] ADD CONSTRAINT [FK_dbo.CompanySettings_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCorridors] ADD CONSTRAINT [FK_dbo.FFCorridors_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[FFBranchDailyPredictions] ADD CONSTRAINT [FK_dbo.FFBranchDailyPredictions_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFDailyPredictions] ADD CONSTRAINT [FK_dbo.FFDailyPredictions_dbo.FFBranchDailyPredictions_BranchDailyPredictionId] FOREIGN KEY ([BranchDailyPredictionId]) REFERENCES [dbo].[FFBranchDailyPredictions] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFZoneSankeyDailies] ADD CONSTRAINT [FK_dbo.FFZoneSankeyDailies_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFZoneSankeyDailies] ADD CONSTRAINT [FK_dbo.FFZoneSankeyDailies_dbo.FFZones_ZoneIdA] FOREIGN KEY ([ZoneIdA]) REFERENCES [dbo].[FFZones] ([ID])
ALTER TABLE [dbo].[FFZoneSankeyDailies] ADD CONSTRAINT [FK_dbo.FFZoneSankeyDailies_dbo.FFZones_ZoneIdB] FOREIGN KEY ([ZoneIdB]) REFERENCES [dbo].[FFZones] ([ID])
ALTER TABLE [dbo].[FFZones] ADD CONSTRAINT [FK_dbo.FFZones_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFZones] ADD CONSTRAINT [FK_dbo.FFZones_dbo.FFBranchFloors_BranchFloorId] FOREIGN KEY ([BranchFloorId]) REFERENCES [dbo].[FFBranchFloors] ([ID])
ALTER TABLE [dbo].[FFBranchFloors] ADD CONSTRAINT [FK_dbo.FFBranchFloors_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraZones] ADD CONSTRAINT [FK_dbo.FFCameraZones_dbo.FFBranchFloors_FFBranchFloor_ID] FOREIGN KEY ([FFBranchFloor_ID]) REFERENCES [dbo].[FFBranchFloors] ([ID])
ALTER TABLE [dbo].[FFZoneDailies] ADD CONSTRAINT [FK_dbo.FFZoneDailies_dbo.FFZones_ZoneID] FOREIGN KEY ([ZoneID]) REFERENCES [dbo].[FFZones] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFZoneHourlies] ADD CONSTRAINT [FK_dbo.FFZoneHourlies_dbo.FFZones_ZoneID] FOREIGN KEY ([ZoneID]) REFERENCES [dbo].[FFZones] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[EslTags] ADD CONSTRAINT [FK_dbo.EslTags_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[EslTags] ADD CONSTRAINT [FK_dbo.EslTags_dbo.ESLTemplates_ESLTemplateId] FOREIGN KEY ([ESLTemplateId]) REFERENCES [dbo].[ESLTemplates] ([Id])
ALTER TABLE [dbo].[EslTags] ADD CONSTRAINT [FK_dbo.EslTags_dbo.Products_ProductId] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Products] ([Id])
ALTER TABLE [dbo].[Products] ADD CONSTRAINT [FK_dbo.Products_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[Products] ADD CONSTRAINT [FK_dbo.Products_dbo.ProductBrands_ProductBrandId] FOREIGN KEY ([ProductBrandId]) REFERENCES [dbo].[ProductBrands] ([Id])
ALTER TABLE [dbo].[Products] ADD CONSTRAINT [FK_dbo.Products_dbo.ProductCategories_ProductCategoryId] FOREIGN KEY ([ProductCategoryId]) REFERENCES [dbo].[ProductCategories] ([Id])
ALTER TABLE [dbo].[ProductBrands] ADD CONSTRAINT [FK_dbo.ProductBrands_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ProductCategories] ADD CONSTRAINT [FK_dbo.ProductCategories_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ProductDailySales] ADD CONSTRAINT [FK_dbo.ProductDailySales_dbo.Products_ProductId] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Products] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[ProductDailySales] ADD CONSTRAINT [FK_dbo.ProductDailySales_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[FFBranchOperatingHours] ADD CONSTRAINT [FK_dbo.FFBranchOperatingHours_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFRegions] ADD CONSTRAINT [FK_dbo.FFRegions_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[SiteGroupLinks] ADD CONSTRAINT [FK_dbo.SiteGroupLinks_dbo.SiteGroups_SiteGroupId] FOREIGN KEY ([SiteGroupId]) REFERENCES [dbo].[SiteGroups] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[SiteGroupLinks] ADD CONSTRAINT [FK_dbo.SiteGroupLinks_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[FFBranchSpecialOperatingHours] ADD CONSTRAINT [FK_dbo.FFBranchSpecialOperatingHours_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[SiteVehicleLinks] ADD CONSTRAINT [FK_dbo.SiteVehicleLinks_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[VirtualReceptionVisitationPurposes] ADD CONSTRAINT [FK_dbo.VirtualReceptionVisitationPurposes_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[FFCameraOperatingHours] ADD CONSTRAINT [FK_dbo.FFCameraOperatingHours_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraSettings] ADD CONSTRAINT [FK_dbo.FFCameraSettings_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraSettingBackUps] ADD CONSTRAINT [FK_dbo.FFCameraSettingBackUps_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraSimulatorSettings] ADD CONSTRAINT [FK_dbo.FFCameraSimulatorSettings_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationTriggers] ADD CONSTRAINT [FK_dbo.NotificationTriggers_dbo.NotificationSettings_NotificationSettingsId] FOREIGN KEY ([NotificationSettingsId]) REFERENCES [dbo].[NotificationSettings] ([Id])
ALTER TABLE [dbo].[FFVerificationStudyReportVideos] ADD CONSTRAINT [FK_dbo.FFVerificationStudyReportVideos_dbo.FFVideoSchedules_FFVideoScheduleId] FOREIGN KEY ([FFVideoScheduleId]) REFERENCES [dbo].[FFVideoSchedules] ([ID])
ALTER TABLE [dbo].[FFVerificationStudyReportVideos] ADD CONSTRAINT [FK_dbo.FFVerificationStudyReportVideos_dbo.FFVerificationStudyReports_FFVerificationStudyReportId] FOREIGN KEY ([FFVerificationStudyReportId]) REFERENCES [dbo].[FFVerificationStudyReports] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFVideoSchedules] ADD CONSTRAINT [FK_dbo.FFVideoSchedules_dbo.FFCameras_FFCameraId] FOREIGN KEY ([FFCameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[VideoSchedules] ADD CONSTRAINT [FK_dbo.VideoSchedules_dbo.FFVideoSchedules_VideoScheduleId] FOREIGN KEY ([VideoScheduleId]) REFERENCES [dbo].[FFVideoSchedules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[VideoScheduleDatas] ADD CONSTRAINT [FK_dbo.VideoScheduleDatas_dbo.FFVideoSchedules_VideoScheduleId] FOREIGN KEY ([VideoScheduleId]) REFERENCES [dbo].[FFVideoSchedules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationAlerts] ADD CONSTRAINT [FK_dbo.NotificationAlerts_dbo.AlertRules_RuleId] FOREIGN KEY ([RuleId]) REFERENCES [dbo].[AlertRules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationAlerts] ADD CONSTRAINT [FK_dbo.NotificationAlerts_dbo.MessageTemplates_MessageTemplateId] FOREIGN KEY ([MessageTemplateId]) REFERENCES [dbo].[MessageTemplates] ([Id])
ALTER TABLE [dbo].[MessageTemplates] ADD CONSTRAINT [FK_dbo.MessageTemplates_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationRecipients] ADD CONSTRAINT [FK_dbo.NotificationRecipients_dbo.NotificationAlerts_NotificationId] FOREIGN KEY ([NotificationId]) REFERENCES [dbo].[NotificationAlerts] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationRecipients] ADD CONSTRAINT [FK_dbo.NotificationRecipients_dbo.UserGroups_UserGroupId] FOREIGN KEY ([UserGroupId]) REFERENCES [dbo].[UserGroups] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[RuleTriggerConditions] ADD CONSTRAINT [FK_dbo.RuleTriggerConditions_dbo.AlertRules_RuleID] FOREIGN KEY ([RuleID]) REFERENCES [dbo].[AlertRules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[RuleActions] ADD CONSTRAINT [FK_dbo.RuleActions_dbo.RuleTriggerConditions_RuleTriggerConditionID] FOREIGN KEY ([RuleTriggerConditionID]) REFERENCES [dbo].[RuleTriggerConditions] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ThresholdMetricRules] ADD CONSTRAINT [FK_dbo.ThresholdMetricRules_dbo.AlertRules_AlertRuleId] FOREIGN KEY ([AlertRuleId]) REFERENCES [dbo].[AlertRules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ApiActions] ADD CONSTRAINT [FK_dbo.ApiActions_dbo.FFVideoSchedules_FFVideoScheduleId] FOREIGN KEY ([FFVideoScheduleId]) REFERENCES [dbo].[FFVideoSchedules] ([ID])
ALTER TABLE [dbo].[AreaPlots] ADD CONSTRAINT [FK_dbo.AreaPlots_dbo.SiteFloorplanDetails_FloorplanID] FOREIGN KEY ([FloorplanID]) REFERENCES [dbo].[SiteFloorplanDetails] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[DevicePlots] ADD CONSTRAINT [FK_dbo.DevicePlots_dbo.SiteFloorplanDetails_FloorplanID] FOREIGN KEY ([FloorplanID]) REFERENCES [dbo].[SiteFloorplanDetails] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[AreaSpaceAmenities] ADD CONSTRAINT [FK_dbo.AreaSpaceAmenities_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[AreaSpaceConfigurations] ADD CONSTRAINT [FK_dbo.AreaSpaceConfigurations_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[AreaSpaceImages] ADD CONSTRAINT [FK_dbo.AreaSpaceImages_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[Bus_BusTripLink] ADD CONSTRAINT [FK_dbo.Bus_BusTripLink_dbo.BusTrips_BusTripId] FOREIGN KEY ([BusTripId]) REFERENCES [dbo].[BusTrips] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[BusTrips] ADD CONSTRAINT [FK_dbo.BusTrips_dbo.BusRoutes_BusRouteId] FOREIGN KEY ([BusRouteId]) REFERENCES [dbo].[BusRoutes] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[BusRoutes] ADD CONSTRAINT [FK_dbo.BusRoutes_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[BusTicketSalesDatas] ADD CONSTRAINT [FK_dbo.BusTicketSalesDatas_dbo.BusDetails_BusDetailId] FOREIGN KEY ([BusDetailId]) REFERENCES [dbo].[BusDetails] ([Id])
ALTER TABLE [dbo].[BusTicketSalesDatas] ADD CONSTRAINT [FK_dbo.BusTicketSalesDatas_dbo.BusStations_BusStationId] FOREIGN KEY ([BusStationId]) REFERENCES [dbo].[BusStations] ([Id])
ALTER TABLE [dbo].[BusTicketSalesDatas] ADD CONSTRAINT [FK_dbo.BusTicketSalesDatas_dbo.BusRoutes_BusRouteId] FOREIGN KEY ([BusRouteId]) REFERENCES [dbo].[BusRoutes] ([Id])
ALTER TABLE [dbo].[BusTicketSalesDatas] ADD CONSTRAINT [FK_dbo.BusTicketSalesDatas_dbo.BusTrips_BusTripId] FOREIGN KEY ([BusTripId]) REFERENCES [dbo].[BusTrips] ([Id])
ALTER TABLE [dbo].[BusStations] ADD CONSTRAINT [FK_dbo.BusStations_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[BusTripStationLinks] ADD CONSTRAINT [FK_dbo.BusTripStationLinks_dbo.BusStations_BusStationId] FOREIGN KEY ([BusStationId]) REFERENCES [dbo].[BusStations] ([Id])
ALTER TABLE [dbo].[BusTripStationLinks] ADD CONSTRAINT [FK_dbo.BusTripStationLinks_dbo.BusTrips_BusTripId] FOREIGN KEY ([BusTripId]) REFERENCES [dbo].[BusTrips] ([Id])
ALTER TABLE [dbo].[CompanyBusPostProcesses] ADD CONSTRAINT [FK_dbo.CompanyBusPostProcesses_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[CompanyBusPostProcessLogs] ADD CONSTRAINT [FK_dbo.CompanyBusPostProcessLogs_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[CompanyCounterSettings] ADD CONSTRAINT [FK_dbo.CompanyCounterSettings_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID])
ALTER TABLE [dbo].[EslAreaSpaceLinks] ADD CONSTRAINT [FK_dbo.EslAreaSpaceLinks_dbo.FFAreas_AreaId] FOREIGN KEY ([AreaId]) REFERENCES [dbo].[FFAreas] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[EslAreaSpaceLinks] ADD CONSTRAINT [FK_dbo.EslAreaSpaceLinks_dbo.EslTags_EslId] FOREIGN KEY ([EslId]) REFERENCES [dbo].[EslTags] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[EslCustomFieldValues] ADD CONSTRAINT [FK_dbo.EslCustomFieldValues_dbo.EslCustomFields_EslCustomFieldId] FOREIGN KEY ([EslCustomFieldId]) REFERENCES [dbo].[EslCustomFields] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFBranch15MinuteValue] ADD CONSTRAINT [FK_dbo.FFBranch15MinuteValue_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFBranchSummaryDailyReports] ADD CONSTRAINT [FK_dbo.FFBranchSummaryDailyReports_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFBranchSummaryHourlyReports] ADD CONSTRAINT [FK_dbo.FFBranchSummaryHourlyReports_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFBranchDailyTargets] ADD CONSTRAINT [FK_dbo.FFBranchDailyTargets_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCamera15MinuteValue] ADD CONSTRAINT [FK_dbo.FFCamera15MinuteValue_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraCountingRecords] ADD CONSTRAINT [FK_dbo.FFCameraCountingRecords_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraCustomerValues] ADD CONSTRAINT [FK_dbo.FFCameraCustomerValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraCustomerValueArchives] ADD CONSTRAINT [FK_dbo.FFCameraCustomerValueArchives_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraHeatValues] ADD CONSTRAINT [FK_dbo.FFCameraHeatValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraMinuteValues] ADD CONSTRAINT [FK_dbo.FFCameraMinuteValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraValues] ADD CONSTRAINT [FK_dbo.FFCameraValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraWifiThresValues] ADD CONSTRAINT [FK_dbo.FFCameraWifiThresValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCameraWifiValues] ADD CONSTRAINT [FK_dbo.FFCameraWifiValues_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCommissionImages] ADD CONSTRAINT [FK_dbo.FFCommissionImages_dbo.FFCommissions_FFCommissionId] FOREIGN KEY ([FFCommissionId]) REFERENCES [dbo].[FFCommissions] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCrossShoppers] ADD CONSTRAINT [FK_dbo.FFCrossShoppers_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFEmailReports] ADD CONSTRAINT [FK_dbo.FFEmailReports_dbo.FFReports_ReportId] FOREIGN KEY ([ReportId]) REFERENCES [dbo].[FFReports] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFReportSummaryDailies] ADD CONSTRAINT [FK_dbo.FFReportSummaryDailies_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFVideoScheduleLogRemarks] ADD CONSTRAINT [FK_dbo.FFVideoScheduleLogRemarks_dbo.FFVideoSchedules_FFVideoScheduleId] FOREIGN KEY ([FFVideoScheduleId]) REFERENCES [dbo].[FFVideoSchedules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FirmwareStages] ADD CONSTRAINT [FK_dbo.FirmwareStages_dbo.FFCameraVersions_FirmwareID] FOREIGN KEY ([FirmwareID]) REFERENCES [dbo].[FFCameraVersions] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FolderSubscribers] ADD CONSTRAINT [FK_dbo.FolderSubscribers_dbo.ReportFolders_ReportFolderID] FOREIGN KEY ([ReportFolderID]) REFERENCES [dbo].[ReportFolders] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FolderSubscribers] ADD CONSTRAINT [FK_dbo.FolderSubscribers_dbo.Users_UserID] FOREIGN KEY ([UserID]) REFERENCES [dbo].[Users] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsAgencies] ADD CONSTRAINT [FK_dbo.GtfsAgencies_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsCalendars] ADD CONSTRAINT [FK_dbo.GtfsCalendars_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsCalendarDates] ADD CONSTRAINT [FK_dbo.GtfsCalendarDates_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsRoutes] ADD CONSTRAINT [FK_dbo.GtfsRoutes_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsShapes] ADD CONSTRAINT [FK_dbo.GtfsShapes_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsStops] ADD CONSTRAINT [FK_dbo.GtfsStops_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsStopTimes] ADD CONSTRAINT [FK_dbo.GtfsStopTimes_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[GtfsTrips] ADD CONSTRAINT [FK_dbo.GtfsTrips_dbo.Companies_company_id] FOREIGN KEY ([company_id]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[HotspotEmails] ADD CONSTRAINT [FK_dbo.HotspotEmails_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[HotspotSettings] ADD CONSTRAINT [FK_dbo.HotspotSettings_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID])
ALTER TABLE [dbo].[JetsonCCTVs] ADD CONSTRAINT [FK_dbo.JetsonCCTVs_dbo.Jetsons_JetsonID] FOREIGN KEY ([JetsonID]) REFERENCES [dbo].[Jetsons] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[JetsonQueueCountings] ADD CONSTRAINT [FK_dbo.JetsonQueueCountings_dbo.JetsonCCTVs_CCTVID] FOREIGN KEY ([CCTVID]) REFERENCES [dbo].[JetsonCCTVs] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[LinkShortenerLinkages] ADD CONSTRAINT [FK_dbo.LinkShortenerLinkages_dbo.LinkShorteners_LinkShortenerId] FOREIGN KEY ([LinkShortenerId]) REFERENCES [dbo].[LinkShorteners] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[MagicMirrorCompanyLinks] ADD CONSTRAINT [FK_dbo.MagicMirrorCompanyLinks_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[MarketingCampaignPeriods] ADD CONSTRAINT [FK_dbo.MarketingCampaignPeriods_dbo.MarketingCampaigns_MarketingCampaignId] FOREIGN KEY ([MarketingCampaignId]) REFERENCES [dbo].[MarketingCampaigns] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[MarketingCampaignRecurringDays] ADD CONSTRAINT [FK_dbo.MarketingCampaignRecurringDays_dbo.MarketingCampaigns_MarketingCampaignId] FOREIGN KEY ([MarketingCampaignId]) REFERENCES [dbo].[MarketingCampaigns] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[MarketingCampaignSites] ADD CONSTRAINT [FK_dbo.MarketingCampaignSites_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[MarketingCampaignSites] ADD CONSTRAINT [FK_dbo.MarketingCampaignSites_dbo.MarketingCampaigns_MarketingCampaignId] FOREIGN KEY ([MarketingCampaignId]) REFERENCES [dbo].[MarketingCampaigns] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[MarketingTrackerReports] ADD CONSTRAINT [FK_dbo.MarketingTrackerReports_dbo.Companies_companyID] FOREIGN KEY ([companyID]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[MarketingTrackerReportSiteLists] ADD CONSTRAINT [FK_dbo.MarketingTrackerReportSiteLists_dbo.MarketingTrackerReports_MarketingTrackerReportID] FOREIGN KEY ([MarketingTrackerReportID]) REFERENCES [dbo].[MarketingTrackerReports] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationEventLogs] ADD CONSTRAINT [FK_dbo.NotificationEventLogs_dbo.NotificationMessages_NotificationMessageId] FOREIGN KEY ([NotificationMessageId]) REFERENCES [dbo].[NotificationMessages] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationGateways] ADD CONSTRAINT [FK_dbo.NotificationGateways_dbo.FFBranches_branchid] FOREIGN KEY ([branchid]) REFERENCES [dbo].[FFBranches] ([ID])
ALTER TABLE [dbo].[NotificationGatewayThresholds] ADD CONSTRAINT [FK_dbo.NotificationGatewayThresholds_dbo.FFCameras_cameraid] FOREIGN KEY ([cameraid]) REFERENCES [dbo].[FFCameras] ([ID])
ALTER TABLE [dbo].[NotificationTypes] ADD CONSTRAINT [FK_dbo.NotificationTypes_dbo.NotificationTriggers_NotificationTriggersId] FOREIGN KEY ([NotificationTriggersId]) REFERENCES [dbo].[NotificationTriggers] ([Id])
ALTER TABLE [dbo].[NotificationUserLinks] ADD CONSTRAINT [FK_dbo.NotificationUserLinks_dbo.NotificationMessages_NotificationMessageId] FOREIGN KEY ([NotificationMessageId]) REFERENCES [dbo].[NotificationMessages] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationUserLinks] ADD CONSTRAINT [FK_dbo.NotificationUserLinks_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID])
ALTER TABLE [dbo].[FFPageAccesses] ADD CONSTRAINT [FK_dbo.FFPageAccesses_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFPageAccessCompanies] ADD CONSTRAINT [FK_dbo.FFPageAccessCompanies_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[PatchStages] ADD CONSTRAINT [FK_dbo.PatchStages_dbo.SoftPatches_PatchID] FOREIGN KEY ([PatchID]) REFERENCES [dbo].[SoftPatches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ProductCurrencyPrices] ADD CONSTRAINT [FK_dbo.ProductCurrencyPrices_dbo.Products_ProductId] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Products] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[ProductCustomPrices] ADD CONSTRAINT [FK_dbo.ProductCustomPrices_dbo.Products_ProductId] FOREIGN KEY ([ProductId]) REFERENCES [dbo].[Products] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[QueueUsageSettings] ADD CONSTRAINT [FK_dbo.QueueUsageSettings_dbo.FFCameras_CameraId] FOREIGN KEY ([CameraId]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ReportSubscribers] ADD CONSTRAINT [FK_dbo.ReportSubscribers_dbo.CustomReports_CustomReportID] FOREIGN KEY ([CustomReportID]) REFERENCES [dbo].[CustomReports] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[RuleEngineActions] ADD CONSTRAINT [FK_dbo.RuleEngineActions_dbo.Rules_RuleId] FOREIGN KEY ([RuleId]) REFERENCES [dbo].[Rules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ServiceSubscriptions] ADD CONSTRAINT [FK_dbo.ServiceSubscriptions_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[SiteNotesForCustomers] ADD CONSTRAINT [FK_dbo.SiteNotesForCustomers_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[SitePendingIssues] ADD CONSTRAINT [FK_dbo.SitePendingIssues_dbo.FFBranches_BranchId] FOREIGN KEY ([BranchId]) REFERENCES [dbo].[FFBranches] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[StandardizedLoginAttemptLogs] ADD CONSTRAINT [FK_dbo.StandardizedLoginAttemptLogs_dbo.StandardizedLoginStatus_StandardizedLoginStatusId] FOREIGN KEY ([StandardizedLoginStatusId]) REFERENCES [dbo].[StandardizedLoginStatus] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserDefinedImportFileHeaderMappings] ADD CONSTRAINT [FK_dbo.UserDefinedImportFileHeaderMappings_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[ConfigurationUserGroups] ADD CONSTRAINT [FK_dbo.ConfigurationUserGroups_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserGroupSettings] ADD CONSTRAINT [FK_dbo.UserGroupSettings_dbo.ConfigurationUserGroups_ConfigurationUserGroupId] FOREIGN KEY ([ConfigurationUserGroupId]) REFERENCES [dbo].[ConfigurationUserGroups] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserGroupLinks] ADD CONSTRAINT [FK_dbo.UserGroupLinks_dbo.ConfigurationUserGroups_ConfigurationUserGroupId] FOREIGN KEY ([ConfigurationUserGroupId]) REFERENCES [dbo].[ConfigurationUserGroups] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserGroupLinks] ADD CONSTRAINT [FK_dbo.UserGroupLinks_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserSiteGroupLinks] ADD CONSTRAINT [FK_dbo.UserSiteGroupLinks_dbo.SiteGroups_SiteGroupId] FOREIGN KEY ([SiteGroupId]) REFERENCES [dbo].[SiteGroups] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserSiteGroupLinks] ADD CONSTRAINT [FK_dbo.UserSiteGroupLinks_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[VirtualReceptionRoles] ADD CONSTRAINT [FK_dbo.VirtualReceptionRoles_dbo.Users_UserId] FOREIGN KEY ([UserId]) REFERENCES [dbo].[Users] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[VirtualReceptionRoles] ADD CONSTRAINT [FK_dbo.VirtualReceptionRoles_dbo.VirtualReceptionVisitationPurposes_VisitationPurposeId] FOREIGN KEY ([VisitationPurposeId]) REFERENCES [dbo].[VirtualReceptionVisitationPurposes] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[WidgetMetricSets] ADD CONSTRAINT [FK_dbo.WidgetMetricSets_dbo.CustomDashboardWidgets_CustomDashboardWidgetID] FOREIGN KEY ([CustomDashboardWidgetID]) REFERENCES [dbo].[CustomDashboardWidgets] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[WidgetSsiTemplates] ADD CONSTRAINT [FK_dbo.WidgetSsiTemplates_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkspaceAttendees] ADD CONSTRAINT [FK_dbo.WorkspaceAttendees_dbo.BookingSchedules_BookingId] FOREIGN KEY ([BookingId]) REFERENCES [dbo].[BookingSchedules] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[WorkWeekConfigurations] ADD CONSTRAINT [FK_dbo.WorkWeekConfigurations_dbo.Companies_CompanyId] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[Companies] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreaSankeyFFAreaProfileDetails] ADD CONSTRAINT [FK_dbo.FFAreaSankeyFFAreaProfileDetails_dbo.FFAreaSankeys_FFAreaSankey_Id] FOREIGN KEY ([FFAreaSankey_Id]) REFERENCES [dbo].[FFAreaSankeys] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFAreaSankeyFFAreaProfileDetails] ADD CONSTRAINT [FK_dbo.FFAreaSankeyFFAreaProfileDetails_dbo.FFAreaProfileDetails_FFAreaProfileDetail_Id] FOREIGN KEY ([FFAreaProfileDetail_Id]) REFERENCES [dbo].[FFAreaProfileDetails] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserGroupsScheduledNotifications] ADD CONSTRAINT [FK_dbo.UserGroupsScheduledNotifications_dbo.UserGroups_UserGroups_ID] FOREIGN KEY ([UserGroups_ID]) REFERENCES [dbo].[UserGroups] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[UserGroupsScheduledNotifications] ADD CONSTRAINT [FK_dbo.UserGroupsScheduledNotifications_dbo.ScheduledNotifications_ScheduledNotifications_ID] FOREIGN KEY ([ScheduledNotifications_ID]) REFERENCES [dbo].[ScheduledNotifications] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCorridorFFCameras] ADD CONSTRAINT [FK_dbo.FFCorridorFFCameras_dbo.FFCorridors_FFCorridor_Id] FOREIGN KEY ([FFCorridor_Id]) REFERENCES [dbo].[FFCorridors] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[FFCorridorFFCameras] ADD CONSTRAINT [FK_dbo.FFCorridorFFCameras_dbo.FFCameras_FFCamera_ID] FOREIGN KEY ([FFCamera_ID]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationTriggersFFCameras] ADD CONSTRAINT [FK_dbo.NotificationTriggersFFCameras_dbo.NotificationTriggers_NotificationTrigger_Id] FOREIGN KEY ([NotificationTrigger_Id]) REFERENCES [dbo].[NotificationTriggers] ([Id]) ON DELETE CASCADE
ALTER TABLE [dbo].[NotificationTriggersFFCameras] ADD CONSTRAINT [FK_dbo.NotificationTriggersFFCameras_dbo.FFCameras_FFCamera_ID] FOREIGN KEY ([FFCamera_ID]) REFERENCES [dbo].[FFCameras] ([ID]) ON DELETE CASCADE
CREATE TABLE [dbo].[__MigrationHistory] (
    [MigrationId] [nvarchar](150) NOT NULL,
    [ContextKey] [nvarchar](300) NOT NULL,
    [Model] [varbinary](max) NOT NULL,
    [ProductVersion] [nvarchar](32) NOT NULL,
    CONSTRAINT [PK_dbo.__MigrationHistory] PRIMARY KEY ([MigrationId], [ContextKey])
)

--Migration_RCCP_20240313_143123.txt
ALTER TABLE [dbo].[CleaningTaskDetails] ADD [CompletionUtcDateTime] [datetime]
ALTER TABLE [dbo].[CleaningTaskDetails] ADD [TaskAge] [int] NOT NULL DEFAULT 0
