

/* This script will migrate a StrataBugs database from v2.1 to v2.1.1 on SQL Server databases
   Remember this will need a commit.
 */


ALTER TABLE EVENTS ADD DEPTHPLUS FLOAT;
ALTER TABLE EVENTS ADD DEPTHMINUS FLOAT;
ALTER TABLE CMPSTDEV ADD CSUPLUS FLOAT;
ALTER TABLE CMPSTDEV ADD CSUMINUS FLOAT;

ALTER TABLE CHTBLOCK
ADD WELL_ID INT;

ALTER TABLE CHTBLOCK
ADD FOREIGN KEY (WELL_ID) REFERENCES WELL_IDENT(WELL_ID);

ALTER TABLE CHTBLOCK
ADD PARENT_ID SMALLINT;

ALTER TABLE CHTBLOCK
ADD FOREIGN KEY (PARENT_ID) REFERENCES CHTBLOCK(BLOCK_ID);


CREATE TABLE CONTROL (
    TABLE_NAME    NVARCHAR(20) PRIMARY KEY NOT NULL, 
    NEXT_ID       INT, 
)

CREATE TABLE DBVERSION (
	VERSION 	NVARCHAR(10),
	DESCR		NVARCHAR(80),
	MODIFIED	DATE
);

INSERT INTO DBVERSION VALUES ('2.1.1', 'Chart block overrides, control table, event err ranges', getdate());

COMMIT;


	