/*
	publ_QuoteBuyoutItems

	Change the size of unnecessarily large columns
	Create search indexes
*/
-------------------------------------------------------------------------------------------------------------------------
IF EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_QuoteBuyoutItems')
    AND name='ix_publ_quoteBuyoutItems_itemId')
BEGIN
	DROP INDEX [ix_publ_quoteBuyoutItems_itemId] ON [dbo].[publ_QuoteBuyoutItems]
END
-------------------------------------------------------------------------------------------------------------------------
GO
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteBuyoutItems]
	ALTER COLUMN [QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsPartNumber] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteBuyoutItems]
	ALTER COLUMN [QuoteBuyoutItems_QuoteBuyoutItems_PartsMasterPartNumber] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteBuyoutItems]
	ALTER COLUMN [QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsBrand] [varchar](16) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteBuyoutItems]
	ALTER COLUMN [QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsCondition] [varchar](16) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [dbo].[publ_QuoteBuyoutItems]
	ALTER COLUMN [QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsLeadtime] [varchar](32) NULL
-------------------------------------------------------------------------------------------------------------------------
GO
-------------------------------------------------------------------------------------------------------------------------
IF NOT EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_QuoteBuyoutItems')
    AND name='idx_publ_QuoteBuyoutItems_Match')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_QuoteBuyoutItems_Match] ON [dbo].[publ_QuoteBuyoutItems]
	(
		[QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsPartNumber] ASC,
		[QuoteBuyoutItems_QuoteBuyoutItems_PartsMasterPartNumber] ASC,
		[QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsBrand] ASC,
		[QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsCondition] 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_QuoteBuyoutItems')
    AND name='idx_publ_QuoteBuyoutItems_ParentSurfaceItemId')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_QuoteBuyoutItems_ParentSurfaceItemId] ON [dbo].[publ_QuoteBuyoutItems]
	(
		[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_QuoteBuyoutItems')
    AND name='ix_publ_quoteBuyoutItems_itemId')
BEGIN
CREATE NONCLUSTERED INDEX [ix_publ_quoteBuyoutItems_itemId] ON [dbo].[publ_QuoteBuyoutItems]
(
	[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
-------------------------------------------------------------------------------------------------------------------------