

--
--    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_Hsql.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;

ALTER TABLE ANN_DIMENSION_METADATAITEM ADD COLUMN dimId BIGINT;
ALTER TABLE ANN_MODEL_DIMENSION ADD COLUMN dimId BIGINT;
ALTER TABLE ANN_DIMENSIONMEMBER ADD COLUMN dimId BIGINT ;
ALTER TABLE ANN_DIMENSION ADD COLUMN compID VARCHAR(255);
ALTER TABLE ANN_CONTEXT ADD COLUMN compID VARCHAR(255);
ALTER TABLE ANN_DIMENSIONMEMBER ADD COLUMN compID VARCHAR(255);

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

DROP INDEX I_NN_CTXT_COMPOSITEID;
DROP INDEX I_NN_DNSN_COMPOSITEID;
DROP INDEX I_NN_DMBR_COMPOSITEID;
DROP INDEX I_NN_DMBR_DIMENSION;
DROP INDEX I_NN_DTTM_DIMENSIONID;
DROP INDEX I_NN_MNSN_ELEMENT;

CREATE UNIQUE INDEX I_NN_CTXT_COMPOSITEID ON ANN_CONTEXT (compID);
CREATE UNIQUE INDEX I_NN_DNSN_COMPOSITEID ON ANN_DIMENSION (compID);
CREATE INDEX I_NN_DMBR_COMPOSITEID ON ANN_DIMENSIONMEMBER (compID);
CREATE INDEX I_NN_DMBR_DIMENSION ON ANN_DIMENSIONMEMBER (dimId);
CREATE INDEX I_NN_DTTM_DIMENSIONID ON ANN_DIMENSION_METADATAITEM (dimId);
CREATE INDEX I_NN_MNSN_ELEMENT ON ANN_MODEL_DIMENSION (dimId);

ALTER TABLE ANN_DIMENSION_METADATAITEM DROP COLUMN dimensionId;
ALTER TABLE ANN_MODEL_DIMENSION DROP COLUMN dimensionId;
ALTER TABLE ANN_DIMENSIONMEMBER DROP COLUMN dimensionId;
ALTER TABLE ANN_DIMENSION DROP COLUMN compositeID;
ALTER TABLE ANN_CONTEXT DROP COLUMN compositeID;
ALTER TABLE ANN_DIMENSIONMEMBER DROP COLUMN compositeID;
 
ALTER TABLE ANN_DIMENSIONMEMBER ADD CONSTRAINT UNQ_dimIdcompID UNIQUE (dimId,compID);

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

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

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

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