-- *********************************************************************
-- 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-1.13.5.xml
-- Ran at: 03/04/20 12:06
-- Against: liquibase@jdbc:postgresql://localhost:5432/squash_dist_cur
-- 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-1.13.5.xml::tm-1.13.5::jthebault::(Checksum: 3:a40d94c52e111a60c770d48f6b660f93)
-- Update TM database version number
UPDATE CORE_CONFIG SET VALUE = '1.13.5' WHERE STR_KEY = 'squashtest.tm.database.version';

INSERT INTO databasechangelog (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('jthebault', 'Update TM database version number', NOW(), 'Update Data', 'EXECUTED', '/var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-1.13.5.xml', 'tm-1.13.5', '2.0.5', '3:a40d94c52e111a60c770d48f6b660f93', 387);

-- Changeset /var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-1.13.5.xml::tm-1.13.5-issue-6291::jthebault::(Checksum: 3:27e505250895da0dd2cb62cc8c6c630b)
-- Delete orphan lines in cuf values. Only for cuf values bind to a removed execution.
DELETE FROM CUSTOM_FIELD_VALUE
      WHERE cfv_id IN (
        SELECT implicit.cfv_id FROM (
          SELECT cfv.cfv_id
          FROM CUSTOM_FIELD_VALUE cfv
          LEFT JOIN EXECUTION exec
          ON exec.execution_id = cfv.bound_entity_id
          WHERE cfv.bound_entity_type = 'EXECUTION'
          AND exec.execution_id IS NULL
      ) implicit
      );

INSERT INTO databasechangelog (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('jthebault', 'Delete orphan lines in cuf values. Only for cuf values bind to a removed execution.', NOW(), 'Custom SQL', 'EXECUTED', '/var/lib/jenkins/jobs/build-squash-tm-distros-1.21/workspace/standalone/target/maven-shared-archive-resources/tm/tm.changelog-1.13.5.xml', 'tm-1.13.5-issue-6291', '2.0.5', '3:27e505250895da0dd2cb62cc8c6c630b', 388);

-- Release Database Lock
-- Release Database Lock
