--liquibase formatted sql

--changeset mvelosob:1 failOnError:true dbms:oracle
--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:"4.4" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE;
UPDATE CTA_CATALOGUE SET STATUS='UPGRADING';
UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MAJOR=4;
UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MINOR=5;
--rollback UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MAJOR=NULL;
--rollback UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MINOR=NULL;
--rollback UPDATE CTA_CATALOGUE SET STATUS='PRODUCTION';

--changeset mvelosob:2 failOnError:true dbms:oracle
--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:"4.4" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE;
CREATE TABLE DISK_INSTANCE(
  DISK_INSTANCE_NAME      VARCHAR2(100)  CONSTRAINT DISK_INSTANCE_DINM_NN NOT NULL,
  USER_COMMENT            VARCHAR2(1000)   CONSTRAINT DISK_INSTANCE_UC_NN   NOT NULL,
  CREATION_LOG_USER_NAME  VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_CLUN_NN NOT NULL,
  CREATION_LOG_HOST_NAME  VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_CLHN_NN NOT NULL,
  CREATION_LOG_TIME       NUMERIC(20, 0)      CONSTRAINT DISK_INSTANCE_CLT_NN  NOT NULL,
  LAST_UPDATE_USER_NAME   VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_LUUN_NN NOT NULL,
  LAST_UPDATE_HOST_NAME   VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_LUHN_NN NOT NULL,
  LAST_UPDATE_TIME        NUMERIC(20, 0)      CONSTRAINT DISK_INSTANCE_LUT_NN  NOT NULL,
  CONSTRAINT DISK_INSTANCE_PK PRIMARY KEY(DISK_INSTANCE_NAME)
);
--rollback DROP TABLE DISK_INSTANCE;

--changeset mvelosob:3 failOnError:true dbms:oracle
--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:"4.4" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE;
CREATE TABLE DISK_INSTANCE_SPACE(
  DISK_INSTANCE_NAME        VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_SPACE_DINM_NN NOT NULL,
  DISK_INSTANCE_SPACE_NAME  VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_SPACE_DISNM_NN NOT NULL,
  FREE_SPACE_QUERY_URL      VARCHAR2(1000)   CONSTRAINT DISK_INSTANCE_SPACE_FSQU_NN NOT NULL,
  REFRESH_INTERVAL          NUMERIC(20, 0)      CONSTRAINT DISK_INSTANCE_SPACE_RI_NN   NOT NULL,
  LAST_REFRESH_TIME         NUMERIC(20, 0)      CONSTRAINT DISK_INSTANCE_SPACE_LRT_NN   NOT NULL,
  FREE_SPACE                NUMERIC(20, 0)      CONSTRAINT DISK_INSTANCE_SPACE_TFS_NN  NOT NULL,
  USER_COMMENT              VARCHAR2(1000)   CONSTRAINT DISK_INSTANCE_SPACE_UC_NN   NOT NULL,
  CREATION_LOG_USER_NAME    VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_SPACE_CLUN_NN NOT NULL,
  CREATION_LOG_HOST_NAME    VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_SPACE_CLHN_NN NOT NULL,
  CREATION_LOG_TIME         NUMERIC(20, 0)      CONSTRAINT DISK_INSTANCE_SPACE_CLT_NN  NOT NULL,
  LAST_UPDATE_USER_NAME     VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_SPACE_LUUN_NN NOT NULL,
  LAST_UPDATE_HOST_NAME     VARCHAR2(100)    CONSTRAINT DISK_INSTANCE_SPACE_LUHN_NN NOT NULL,
  LAST_UPDATE_TIME          NUMERIC(20, 0)      CONSTRAINT DISK_INSTANCE_SPACE_LUT_NN  NOT NULL,
  CONSTRAINT DISK_INSTANCE_SPACE_PK PRIMARY KEY(DISK_INSTANCE_NAME, DISK_INSTANCE_SPACE_NAME),
  CONSTRAINT DISK_INSTANCE_SPACE_DIN_FK FOREIGN KEY(DISK_INSTANCE_NAME) REFERENCES DISK_INSTANCE(DISK_INSTANCE_NAME)
);
--rollback DROP TABLE DISK_INSTANCE_SPACE;


--changeset mvelosob:4 failOnError:true dbms:oracle
--preconditions onFail:HALT onError:HALT
--precondition-sql-check expectedResult:"4.4" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE;
UPDATE CTA_CATALOGUE SET STATUS='PRODUCTION';
UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MAJOR=4;
UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MINOR=5;
UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MAJOR=NULL;
UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MINOR=NULL;
--rollback UPDATE CTA_CATALOGUE SET STATUS='UPGRADING';
--rollback UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MAJOR=4;
--rollback UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MINOR=4;
--rollback UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MAJOR=4;
--rollback UPDATE CTA_CATALOGUE SET NEXT_SCHEMA_VERSION_MINOR=5;
