/*
	publ_QuoteItems

	Change the size of unnecessarily large columns
	Create search indexes
*/
-------------------------------------------------------------------------------------------------------------------------
IF NOT EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_QuoteItems')
    AND name='ix_publ_quoteItems_itemId')
BEGIN
	DROP INDEX [ix_publ_quoteItems_itemId] ON [dbo].[publ_QuoteItems]
END
-------------------------------------------------------------------------------------------------------------------------
GO
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_InventoryItemsUniqueNumber] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_PartsMasterPartNumber] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsPartNumber] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsDescription] [varchar](256) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsBrand] [varchar](16) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsCondition] [varchar](16) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsSupplier] [varchar](128) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsLeadTime] [varchar](32) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsCategory] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsSubcategory] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsWarehouseLocation] [varchar](128) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsMinorCode] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsBinLocation] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteItems]
	ALTER COLUMN [QuoteItems_QuoteItems_QuoteItemsSupplierCurrency] [varchar](16) NULL
-------------------------------------------------------------------------------------------------------------------------
GO
-------------------------------------------------------------------------------------------------------------------------
IF NOT EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_QuoteItems')
    AND name='idx_publ_QuoteItems_Match')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_QuoteItems_Match] ON [dbo].[publ_QuoteItems]
	(
		[ParentSurfaceItemId] ASC,
		[QuoteItems_QuoteItems_PartsMasterPartNumber] ASC,
		[QuoteItems_QuoteItems_QuoteItemsPartNumber] ASC,
		[QuoteItems_QuoteItems_QuoteItemsBrand] ASC,
		[QuoteItems_QuoteItems_QuoteItemsCondition] ASC,
		[QuoteItems_QuoteItems_QuoteItemsSupplier] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END
-------------------------------------------------------------------------------------------------------------------------
IF NOT EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_QuoteItems')
    AND name='idx_publ_QuoteItems_ParentSurfaceItemId')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_QuoteItems_ParentSurfaceItemId] ON [dbo].[publ_QuoteItems]
	(
		[ParentSurfaceItemId] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END
-------------------------------------------------------------------------------------------------------------------------
IF NOT EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_QuoteItems')
    AND name='ix_publ_quoteItems_itemId')
BEGIN
	CREATE NONCLUSTERED INDEX [ix_publ_quoteItems_itemId] ON [dbo].[publ_QuoteItems]
	(
		[itemID] ASC,
		[ParentSurfaceItemId] ASC
	)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END
-------------------------------------------------------------------------------------------------------------------------
GO
-------------------------------------------------------------------------------------------------------------------------