-- *********************************************************************
-- Update Database Script
-- *********************************************************************
-- Change Log: /var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/upgrade/upgrade.changelog-up-to-0.17.0.xml
-- Ran at: 03/04/20 12:06
-- Against: SA@jdbc:h2:/var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/incremental-upgrade-database/squash-tm
-- Liquibase version: 2.0.5
-- *********************************************************************

-- Lock Database
-- Changeset /var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml::tm-0.17.0.01::gfouquet::(Checksum: 3:98ccb741049fc7ae4b5e4d02b64ae4e8)
-- This table stores "action" tests steps, i.e. steps with an action and expected result, which were formerly stored in TEST_STEP
CREATE TABLE ACTION_TEST_STEP (TEST_STEP_ID BIGINT NOT NULL, ACTION LONGVARCHAR NOT NULL, EXPECTED_RESULT LONGVARCHAR DEFAULT null, ATTACHMENT_LIST_ID BIGINT, CONSTRAINT pk_action_step PRIMARY KEY (TEST_STEP_ID), CONSTRAINT fk_action_test_step_attachment_list FOREIGN KEY (ATTACHMENT_LIST_ID) REFERENCES ATTACHMENT_LIST(ATTACHMENT_LIST_ID), CONSTRAINT fk_action_step_test_step FOREIGN KEY (TEST_STEP_ID) REFERENCES TEST_STEP(TEST_STEP_ID));

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('gfouquet', 'This table stores "action" tests steps, i.e. steps with an action and expected result, which were formerly stored in TEST_STEP', NOW(), 'Create Table', 'EXECUTED', '/var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml', 'tm-0.17.0.01', '2.0.5', '3:98ccb741049fc7ae4b5e4d02b64ae4e8', 56);

-- Changeset /var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml::tm-0.17.0.02::gfouquet::(Checksum: 3:a54eda81c8b073f49f3c48b969724007)
-- Data migration from TEST_STEP to ACTION_TEST_STEP
insert into ACTION_TEST_STEP (TEST_STEP_ID, ACTION, EXPECTED_RESULT, ATTACHMENT_LIST_ID) select TEST_STEP_ID, ACTION, EXPECTED_RESULT, ATTACHMENT_LIST_ID from TEST_STEP;

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('gfouquet', 'Data migration from TEST_STEP to ACTION_TEST_STEP', NOW(), 'Custom SQL', 'EXECUTED', '/var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml', 'tm-0.17.0.02', '2.0.5', '3:a54eda81c8b073f49f3c48b969724007', 57);

-- Changeset /var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml::tm-0.17.0.03::gfouquet::(Checksum: 3:24b184e1522e87284c5bc4435010d822)
-- Removes useless comlumns from TEST_STEP
ALTER TABLE TEST_STEP DROP CONSTRAINT fk_test_step__attachment_list;

ALTER TABLE TEST_STEP DROP COLUMN ACTION;

ALTER TABLE TEST_STEP DROP COLUMN EXPECTED_RESULT;

ALTER TABLE TEST_STEP DROP COLUMN ATTACHMENT_LIST_ID;

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('gfouquet', 'Removes useless comlumns from TEST_STEP', NOW(), 'Drop Foreign Key Constraint, Drop Column (x3)', 'EXECUTED', '/var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml', 'tm-0.17.0.03', '2.0.5', '3:24b184e1522e87284c5bc4435010d822', 58);

-- Changeset /var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml::tm-0.17.0.04::gfouquet::(Checksum: 3:f17d3f5ef7678112090526434ab02012)
-- This table stores "call" tests steps, i.e. steps which call an entire test case
CREATE TABLE CALL_TEST_STEP (TEST_STEP_ID BIGINT NOT NULL, CALLED_TEST_CASE_ID BIGINT NOT NULL, CONSTRAINT pk_call_step PRIMARY KEY (TEST_STEP_ID), CONSTRAINT fk_call_step_test_step FOREIGN KEY (TEST_STEP_ID) REFERENCES TEST_STEP(TEST_STEP_ID), CONSTRAINT fk_call_step_called_test_case FOREIGN KEY (CALLED_TEST_CASE_ID) REFERENCES TEST_CASE(TCLN_ID));

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('gfouquet', 'This table stores "call" tests steps, i.e. steps which call an entire test case', NOW(), 'Create Table', 'EXECUTED', '/var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-0.17.0.xml', 'tm-0.17.0.04', '2.0.5', '3:f17d3f5ef7678112090526434ab02012', 59);

-- Release Database Lock
-- Release Database Lock
