/*
 * $Id: migprep77.sql 84480 2007-07-24 06:34:27Z pca $
 *
 * Prepare to migrate a ManageSoft 7.6 database into ManageSoft 7.6 format.
 *
 * Use this first, then schema.sql, OpQueries.sql, then migpost.sql, and finally
 * install Managesoft 7.6 which will create the stored procedures.
 *
 * The aim here is to make minimal changes that will allow schema.sql
 * to succeed in creating any new objects, before migpost.sql finishes
 * reshaping some tables and dropping any unused objects.
 *
 * Copyright 1995-2005 ManageSoft Corporation Ltd ABN 40 052 412 156. All rights reserved.
 */

USE ManageSoft

exec sp_rename 'TargetedPackage', 'PackageApplies'


GO

-- Add the new EffectiveUntil attribute of AllocationDetails
ALTER TABLE AllocationDetails
	ADD EffectiveUntil datetime NULL
GO

IF EXISTS (
		SELECT * FROM sysindexes
		WHERE name = 'UQ_AllocationDetails'
	)
	ALTER TABLE [dbo].[AllocationDetails] DROP CONSTRAINT [UQ_AllocationDetails]
GO

ALTER TABLE [dbo].[AllocationDetails] ADD CONSTRAINT [UQ_AllocationDetails] UNIQUE  NONCLUSTERED 
	(
		[Action],
		[EffectiveFrom],
		[EffectiveFromIsLocal],
		[EffectiveUntil],
		[Wake],
		[PostponeNoLaterThan],
		[PostponeNoLaterThanIsLocal],
		[PostponePeriod],
		[PostponeLatest],
		[PostponeOKForLowBandwidth],
		[PostponeOKForAnyReason],
		[Exclusive]
	)  ON [PRIMARY] 
GO


