diff --git a/catalogue/SchemaSqlStatementsReader.cpp b/catalogue/SchemaSqlStatementsReader.cpp index 254d5c07dd49b117616020b83df06e3605f3cb89..1c37a57e44f5e7e044953d8bf3a46d5809726765 100644 --- a/catalogue/SchemaSqlStatementsReader.cpp +++ b/catalogue/SchemaSqlStatementsReader.cpp @@ -156,8 +156,18 @@ MapSqlStatementsReader::~MapSqlStatementsReader() { } std::list<std::string> MapSqlStatementsReader::getStatements(){ - std::string schema = AllCatalogueSchema::mapSchema[m_catalogueVersion][getDatabaseType()]; - return getAllStatementsFromSchema(schema); + std::map<std::string,std::string> mapVersionSchemas; + try { + mapVersionSchemas = AllCatalogueSchema::mapSchema.at(m_catalogueVersion); + } catch(const std::out_of_range &ex){ + throw cta::exception::Exception("No schema has been found for version number "+m_catalogueVersion); + } + try { + std::string schema = mapVersionSchemas.at(getDatabaseType()); + return getAllStatementsFromSchema(schema); + } catch(const std::out_of_range &ex){ + throw cta::exception::Exception("No schema has been found for database type "+getDatabaseType()); + } } }} diff --git a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql index 7efa089fdab1e8a35b68b76528e0507d7df41132..22d3713a172c6242f1f37bb6830249182179f679 100644 --- a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql +++ b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql @@ -1,21 +1,31 @@ --liquibase formatted sql --changeset ccaffy:1 failOnError:true dbms:oracle +--preconditions onFail:HALT onError:HALT +--precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; ALTER INDEX TEMP_T_F_I_B_ARCHIVE_FILE_ID_I RENAME TO TEMP_T_F_I_B_AFI_IDX; --rollback ALTER INDEX TEMP_T_F_I_B_AFI_IDX RENAME TO TEMP_T_F_I_B_ARCHIVE_FILE_ID_I; --changeset ccaffy:2 failOnError:true dbms:oracle +--preconditions onFail:HALT onError:HALT +--precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; ALTER TABLE USAGESTATS RENAME CONSTRAINT NN_USAGESTATS_GID TO USAGESTATS_GID_NN; --rollback ALTER TABLE USAGESTATS RENAME CONSTRAINT USAGESTATS_GID_NN TO NN_USAGESTATS_GID; --changeset ccaffy:3 failOnError:true dbms:oracle +--preconditions onFail:HALT onError:HALT +--precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; ALTER TABLE USAGESTATS RENAME CONSTRAINT NN_USAGESTATS_TS TO USAGESTATS_TS_NN; --rollback ALTER TABLE USAGESTATS RENAME CONSTRAINT USAGESTATS_TS_NN TO NN_USAGESTATS_TS; --changeset ccaffy:4 failOnError:true dbms:oracle +--preconditions onFail:HALT onError:HALT +--precondition-sql-check expectedResult:"1.0" SELECT CONCAT(CONCAT(CAST(SCHEMA_VERSION_MAJOR as VARCHAR(10)),'.'), CAST(SCHEMA_VERSION_MINOR AS VARCHAR(10))) AS CATALOGUE_VERSION FROM CTA_CATALOGUE; ALTER TABLE ARCHIVE_ROUTE ADD CONSTRAINT ARCHIVE_ROUTE_SCI_TPI_UN UNIQUE(STORAGE_CLASS_ID, TAPE_POOL_ID); --rollback ALTER TABLE ARCHIVE_ROUTE DROP CONSTRAINT ARCHIVE_ROUTE_SCI_TPI_UN; --changeset ccaffy:5 failOnError:true dbms:oracle +--preconditions onFail:HALT onError:HALT +--precondition-sql-check expectedResult:"1.0" 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 SCHEMA_VERSION_MINOR=1 --rollback UPDATE CTA_CATALOGUE SET SCHEMA_VERSION_MINOR=0 diff --git a/catalogue/migrations/liquibase/properties-examples/example-liquibase-oracle.properties b/catalogue/migrations/liquibase/properties-examples/example-liquibase-oracle.properties index 2c76bf028c001b2e7353c37c1a44ef0a002e76f4..56327fcafde3f52108035a507f851717e8fd906c 100644 --- a/catalogue/migrations/liquibase/properties-examples/example-liquibase-oracle.properties +++ b/catalogue/migrations/liquibase/properties-examples/example-liquibase-oracle.properties @@ -1,5 +1,6 @@ +# url: jdbc:oracle:thin:@HOST:PORT/SERVICE_NAME -username: MYSCHEMA -password: password +username: USERNAME +password: PASSWORD driver: oracle.jdbc.OracleDriver classpath: ../drivers/ojdbc8.jar \ No newline at end of file