-- Migration: 008_CreateItemTable
-- Source: OLD/Database/Tables/Item.sql
-- Changes: DATETIME -> DATETIME2(7)

IF NOT EXISTS (SELECT * FROM sys.tables WHERE name = 'Item' AND schema_id = SCHEMA_ID('dbo'))
BEGIN
    CREATE TABLE [dbo].[Item]
    (
        [ShortItemNumber] BIGINT NOT NULL,
        [ItemNumber] VARCHAR(25) NOT NULL,
        [Description] VARCHAR(30) NULL,
        [PlanningFamily] VARCHAR(3) NULL,
        [StockingType] CHAR(1) NULL,
        [LastUpdateDT] DATETIME2(7) NOT NULL,
        CONSTRAINT [PK_Item] PRIMARY KEY CLUSTERED([ShortItemNumber])
    );
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE name = 'IX_Item_ItemNumber' AND object_id = OBJECT_ID('dbo.Item'))
BEGIN
    CREATE INDEX [IX_Item_ItemNumber] ON [dbo].[Item]([ItemNumber]);
END
GO
