﻿CREATE TABLE [dbo].[mfr__servicerequests] (
    [Id]                                 BIGINT         NOT NULL,
    [Name]                               NVARCHAR (255) NULL,
    [ExternalId]                         NVARCHAR (255) NULL,
    [InvoiceId]                          NVARCHAR (255) NULL,
    [ClosedAt]                           DATETIME       NULL,
    [ReleasedAt]                         DATETIME       NULL,
    [WorkDoneAt]                         DATETIME       NULL,
    [TargetTimeInMinutes]                BIGINT         NOT NULL,
    [DateModified]                       DATETIME       NULL,
    [DateOfCreation]                     DATETIME       NULL,
    [DueDateRangeStart]                  DATETIME       NULL,
    [DueDateRangeEnd]                    DATETIME       NULL,
    [PortalLink]                         NVARCHAR (255) NULL,
    [CostCenterId]                       BIGINT         NULL,
    [Description]                        NVARCHAR (MAX) NULL,
    [State]                              VARCHAR (100)  NULL,
    [CustomValues]                       NVARCHAR (MAX) NOT NULL,
    [CurrentOwnerId]                     BIGINT         NULL,
    [CustomerId]                         BIGINT         NULL,
    [ParentServiceRequestId]             BIGINT         NULL,
    [Location#ID]                        BIGINT         NULL,
    [Version]                            INT            NOT NULL,
    [IsTemplate]                         BIT            NOT NULL,
    [IsTemplateMobile]                   BIT            NOT NULL,
    [CreateFromServiceRequestTemplateId] BIGINT         NOT NULL,
    [Type]                               NVARCHAR (255) NULL,
    CONSTRAINT [PK_mfr__servicerequest] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
CREATE NONCLUSTERED INDEX [mfr__servicerequests__ix1]
    ON [dbo].[mfr__servicerequests]([InvoiceId] ASC)
    INCLUDE([Name], [DateOfCreation], [CustomerId]);

