

--
--    Licensed Materials - Property of IBM
--    
--    BI and PM: ANS
--    
--    (c) Copyright IBM Corp. 2003, 2010.
--    
--    US Government Users Restricted RigANS - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
--    


-------------------------------------------------------------------------------
-- ANS2_UPDATE_mssql.SQL	   *DO NOT EDIT*	Data Store Version: 2		 
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$100-- backup create begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$110-- backup inserts begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$130-- views drop begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$140-- tables drop begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$200-- recreate tables begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$202-- primary keys add begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$203-- alter tables begin
-------------------------------------------------------------------------------

ALTER TABLE ANN_DIMENSIONMEMBER DROP CONSTRAINT UNQ_dimensionIdcompositeID
go
ALTER TABLE ANN_DIMENSION_METADATAITEM ADD dimId BIGINT
go
ALTER TABLE ANN_MODEL_DIMENSION ADD dimId BIGINT
go
ALTER TABLE ANN_DIMENSIONMEMBER ADD dimId BIGINT NOT NULL DEFAULT 0
go
ALTER TABLE ANN_DIMENSION ADD compID VARCHAR(255)
go
ALTER TABLE ANN_CONTEXT ADD compID VARCHAR(255)
go
ALTER TABLE ANN_DIMENSIONMEMBER ADD compID VARCHAR(255) NOT NULL DEFAULT ''
go


UPDATE ANN_DIMENSION_METADATAITEM SET dimId = dimensionId
go
UPDATE ANN_MODEL_DIMENSION SET dimId = dimensionId
go
UPDATE ANN_DIMENSIONMEMBER SET dimId = dimensionId
go
UPDATE ANN_DIMENSION SET compID = compositeID
go
UPDATE ANN_CONTEXT SET compID = compositeID
go
UPDATE ANN_DIMENSIONMEMBER SET compID = compositeID
go

DROP INDEX ANN_CONTEXT.I_NN_CTXT_COMPOSITEID
go
DROP INDEX ANN_DIMENSION.I_NN_DNSN_COMPOSITEID
go
DROP INDEX ANN_DIMENSIONMEMBER.I_NN_DMBR_COMPOSITEID
go
DROP INDEX ANN_DIMENSIONMEMBER.I_NN_DMBR_DIMENSION
go
DROP INDEX ANN_DIMENSION_METADATAITEM.I_NN_DTTM_DIMENSIONID
go
DROP INDEX ANN_MODEL_DIMENSION.I_NN_MNSN_ELEMENT
go

CREATE UNIQUE INDEX I_NN_CTXT_COMPOSITEID ON ANN_CONTEXT (compID)
go
CREATE UNIQUE INDEX I_NN_DNSN_COMPOSITEID ON ANN_DIMENSION (compID)
go
CREATE INDEX I_NN_DMBR_COMPOSITEID ON ANN_DIMENSIONMEMBER (compID)
CREATE INDEX I_NN_DMBR_DIMENSION ON ANN_DIMENSIONMEMBER (dimId)
go
CREATE INDEX I_NN_DTTM_DIMENSIONID ON ANN_DIMENSION_METADATAITEM (dimId)
go
CREATE INDEX I_NN_MNSN_ELEMENT ON ANN_MODEL_DIMENSION (dimId)
go
ALTER TABLE ANN_DIMENSIONMEMBER ADD CONSTRAINT UNQ_dimIdcompID UNIQUE (dimId,compID)
go

ALTER TABLE ANN_DIMENSION_METADATAITEM DROP COLUMN dimensionId
go
ALTER TABLE ANN_MODEL_DIMENSION DROP COLUMN dimensionId
go
ALTER TABLE ANN_DIMENSIONMEMBER DROP COLUMN dimensionId
go
ALTER TABLE ANN_DIMENSION DROP COLUMN compositeID
go
ALTER TABLE ANN_CONTEXT DROP COLUMN compositeID
go
ALTER TABLE ANN_DIMENSIONMEMBER DROP COLUMN compositeID
go

-------------------------------------------------------------------------------
--$210-- views create begin
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$220-- server data inserts begin
-------------------------------------------------------------------------------
INSERT INTO ANN_VERSION(id, version) VALUES ('2', 2);
go
 -------------------------------------------------------------------------------
 --$230-- restore inserts begin
 -------------------------------------------------------------------------------

 -------------------------------------------------------------------------------
 --$250-- backup drop begin
 -------------------------------------------------------------------------------

-------------------------------------------------------------------------------
--$260-- end sql by function
-------------------------------------------------------------------------------
-- END ANS2_UPDATE_mssql.SQL			*	DO NOT EDIT	 * 		 
-------------------------------------------------------------------------------
