/*
	publ_PartsAlternates

	Change the size of unnecessarily large columns
	Create search indexes
*/
-------------------------------------------------------------------------------------------------------------------------
IF EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_PartsAlternates')
    AND name='ix_PartsAlternates_ParentSurfaceItemId')
BEGIN
	DROP INDEX [ix_PartsAlternates_ParentSurfaceItemId] ON [dbo].[publ_PartsAlternates]
END
-------------------------------------------------------------------------------------------------------------------------
GO
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [publ_PartsAlternates]
	ALTER COLUMN [PartsAlternates_PartsAlternates_PartsMasterCEPNumber] [varchar](32) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [publ_PartsAlternates]
	ALTER COLUMN [PartsAlternates_PartsAlternates_PartsMasterPartNumber] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
ALTER TABLE [publ_PartsAlternates]
	ALTER COLUMN [PartsAlternates_PartsAlternates_AlternatePartNumber] [varchar](64) NULL
-------------------------------------------------------------------------------------------------------------------------
GO
-------------------------------------------------------------------------------------------------------------------------
IF NOT EXISTS (
    SELECT * FROM sys.indexes 
    WHERE object_id = OBJECT_ID('dbo.publ_PartsAlternates')
    AND name='idx_publ_PartsAlternates_AlternatePartNumber')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_PartsAlternates_AlternatePartNumber] ON [dbo].[publ_PartsAlternates]
	(
		[PartsAlternates_PartsAlternates_AlternatePartNumber] 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_PartsAlternates')
    AND name='idx_publ_PartsAlternates_CEPNumber')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_PartsAlternates_CEPNumber] ON [dbo].[publ_PartsAlternates]
	(
		[PartsAlternates_PartsAlternates_PartsMasterCEPNumber] 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_PartsAlternates')
    AND name='idx_publ_PartsAlternates_itemID')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_PartsAlternates_itemID] ON [dbo].[publ_PartsAlternates]
	(
		[itemID] 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_PartsAlternates')
    AND name='idx_publ_PartsAlternates_MasterPartNumber')
BEGIN
	CREATE NONCLUSTERED INDEX [idx_publ_PartsAlternates_MasterPartNumber] ON [dbo].[publ_PartsAlternates]
	(
		[PartsAlternates_PartsAlternates_PartsMasterPartNumber] 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_PartsAlternates')
    AND name='ix_PartsAlternates_ParentSurfaceItemId')
BEGIN
	CREATE NONCLUSTERED INDEX [ix_PartsAlternates_ParentSurfaceItemId] ON [dbo].[publ_PartsAlternates]
	(
		[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
-------------------------------------------------------------------------------------------------------------------------

