

/* This script will migrate a StrataBugs database from v2.1 to v2.1.1 on Access databases
 */

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

ALTER TABLE CHTBLOCK
ADD COLUMN  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    TEXT(20) PRIMARY KEY NOT NULL, 
    NEXT_ID       INT
);

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

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

COMMIT;


	