﻿CREATE TABLE [dbo].[mfr__items] (
    [Id]                   BIGINT          NOT NULL,
    [Version]              INT             NOT NULL,
    [QuantityHours]        NUMERIC (10, 3) NOT NULL,
    [PlannedQuantityHours] NUMERIC (10, 3) NOT NULL,
    [ItemTypeId]           BIGINT          NULL,
    [ItemNumber]           VARCHAR (255)   NULL,
    [TrackingId]           VARCHAR (255)   NULL,
    [Manufacture]          VARCHAR (255)   NULL,
    [Price]                NUMERIC (10, 3) NOT NULL,
    [Costs]                NUMERIC (10, 3) NULL,
    [NameOrNumber]         NVARCHAR (255)  NULL,
    [CustomValues]         NVARCHAR (MAX)  NULL,
    [Note]                 NVARCHAR (MAX)  NULL,
    [ExternalId]           NVARCHAR (255)  NULL,
    [Discount]             NUMERIC (10, 3) NOT NULL,
    [VAT]                  NUMERIC (10, 3) NOT NULL,
    [IsManual]             BIT             NOT NULL,
    [SortOrder]            INT             NOT NULL,
    [Type]                 VARCHAR (255)   NULL,
    [ServiceRequestId]     BIGINT          NOT NULL,
    [ServiceObjectId]      BIGINT          NOT NULL,
    [CreatorId]            BIGINT          NOT NULL,
    [UnitId]               BIGINT          NULL,
    [UnitString]           VARCHAR (50)    NULL,
    CONSTRAINT [PK_mfr__item] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
CREATE NONCLUSTERED INDEX [mfr__items__ix1]
    ON [dbo].[mfr__items]([ServiceRequestId] ASC)
    INCLUDE([QuantityHours], [Price]);

