diff --git a/catalogue/1.1/mysql_catalogue_schema.sql b/catalogue/1.1/mysql_catalogue_schema.sql index 458adb65e7816002ade2889fbb21c51936db4588..ba96bfbb6c78be1d68b6532d7661bbdadf72a1c9 100644 --- a/catalogue/1.1/mysql_catalogue_schema.sql +++ b/catalogue/1.1/mysql_catalogue_schema.sql @@ -24,8 +24,7 @@ CREATE TABLE CTA_CATALOGUE( SCHEMA_VERSION_MINOR BIGINT UNSIGNED CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL, NEXT_SCHEMA_VERSION_MAJOR BIGINT UNSIGNED, NEXT_SCHEMA_VERSION_MINOR BIGINT UNSIGNED, - STATUS VARCHAR(100), - CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING')) + STATUS VARCHAR(100) ); CREATE TABLE ADMIN_USER( ADMIN_USER_NAME VARCHAR(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL, diff --git a/catalogue/1.1/oracle_catalogue_schema.sql b/catalogue/1.1/oracle_catalogue_schema.sql index 424304fd44ddd7df8311d8bfac6f5636db722034..14e458c836e70c764f52ce6ffb33b76fd5abe6af 100644 --- a/catalogue/1.1/oracle_catalogue_schema.sql +++ b/catalogue/1.1/oracle_catalogue_schema.sql @@ -46,8 +46,7 @@ CREATE TABLE CTA_CATALOGUE( SCHEMA_VERSION_MINOR NUMERIC(20, 0) CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL, NEXT_SCHEMA_VERSION_MAJOR NUMERIC(20, 0), NEXT_SCHEMA_VERSION_MINOR NUMERIC(20, 0), - STATUS VARCHAR2(100), - CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING')) + STATUS VARCHAR2(100) ); CREATE TABLE ADMIN_USER( ADMIN_USER_NAME VARCHAR2(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL, @@ -315,4 +314,6 @@ INSERT INTO CTA_CATALOGUE( VALUES( 1, 1); +ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (NEXT_SCHEMA_VERSION_MAJOR IS NOT NULL AND NEXT_SCHEMA_VERSION_MINOR IS NOT NULL AND STATUS='UPGRADING')) INITIALLY DEFERRED; + COMMIT; diff --git a/catalogue/1.1/postgres_catalogue_schema.sql b/catalogue/1.1/postgres_catalogue_schema.sql index 45441bcbfb7c23d7f881e7c0a4cd9191c3918586..662305e2cdd3cb0cbaf0eea095d6857d733e4bdf 100644 --- a/catalogue/1.1/postgres_catalogue_schema.sql +++ b/catalogue/1.1/postgres_catalogue_schema.sql @@ -31,8 +31,7 @@ CREATE TABLE CTA_CATALOGUE( SCHEMA_VERSION_MINOR NUMERIC(20, 0) CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL, NEXT_SCHEMA_VERSION_MAJOR NUMERIC(20, 0), NEXT_SCHEMA_VERSION_MINOR NUMERIC(20, 0), - STATUS VARCHAR(100), - CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING')) + STATUS VARCHAR(100) ); CREATE TABLE ADMIN_USER( ADMIN_USER_NAME VARCHAR(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL, diff --git a/catalogue/1.1/sqlite_catalogue_schema.sql b/catalogue/1.1/sqlite_catalogue_schema.sql index d900684cbff8f69b2159388ce75f1e5609d049f5..b730593c347fe5074544217b5b1e9301c5a36e81 100644 --- a/catalogue/1.1/sqlite_catalogue_schema.sql +++ b/catalogue/1.1/sqlite_catalogue_schema.sql @@ -15,8 +15,7 @@ CREATE TABLE CTA_CATALOGUE( SCHEMA_VERSION_MINOR INTEGER CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL, NEXT_SCHEMA_VERSION_MAJOR INTEGER, NEXT_SCHEMA_VERSION_MINOR INTEGER, - STATUS VARCHAR(100), - CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING')) + STATUS VARCHAR(100) ); CREATE TABLE ADMIN_USER( ADMIN_USER_NAME VARCHAR(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL, diff --git a/catalogue/AllCatalogueSchema.hpp b/catalogue/AllCatalogueSchema.hpp index c6fc1012748921dcb4cd46d774dc83b7891267c6..d3e567a99bca6d26c79f122860e57bb853791b98 100644 --- a/catalogue/AllCatalogueSchema.hpp +++ b/catalogue/AllCatalogueSchema.hpp @@ -1271,8 +1271,7 @@ namespace catalogue{ " SCHEMA_VERSION_MINOR NUMERIC(20, 0) CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL," " NEXT_SCHEMA_VERSION_MAJOR NUMERIC(20, 0)," " NEXT_SCHEMA_VERSION_MINOR NUMERIC(20, 0)," - " STATUS VARCHAR2(100)," - " CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING'))" + " STATUS VARCHAR2(100)" ");" "CREATE TABLE ADMIN_USER(" " ADMIN_USER_NAME VARCHAR2(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL," @@ -1540,6 +1539,8 @@ namespace catalogue{ "VALUES(" " 1," " 1);" + "ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (NEXT_SCHEMA_VERSION_MAJOR IS NOT NULL AND NEXT_SCHEMA_VERSION_MINOR IS NOT NULL AND STATUS='UPGRADING')) INITIALLY DEFERRED;" + "" "COMMIT;" }, {"mysql", "CREATE TABLE ARCHIVE_FILE_ID(" @@ -1568,8 +1569,7 @@ namespace catalogue{ " SCHEMA_VERSION_MINOR BIGINT UNSIGNED CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL," " NEXT_SCHEMA_VERSION_MAJOR BIGINT UNSIGNED," " NEXT_SCHEMA_VERSION_MINOR BIGINT UNSIGNED," - " STATUS VARCHAR(100)," - " CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING'))" + " STATUS VARCHAR(100)" ");" "CREATE TABLE ADMIN_USER(" " ADMIN_USER_NAME VARCHAR(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL," @@ -1855,8 +1855,7 @@ namespace catalogue{ " SCHEMA_VERSION_MINOR INTEGER CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL," " NEXT_SCHEMA_VERSION_MAJOR INTEGER," " NEXT_SCHEMA_VERSION_MINOR INTEGER," - " STATUS VARCHAR(100)," - " CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING'))" + " STATUS VARCHAR(100)" ");" "CREATE TABLE ADMIN_USER(" " ADMIN_USER_NAME VARCHAR(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL," @@ -2158,8 +2157,7 @@ namespace catalogue{ " SCHEMA_VERSION_MINOR NUMERIC(20, 0) CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL," " NEXT_SCHEMA_VERSION_MAJOR NUMERIC(20, 0)," " NEXT_SCHEMA_VERSION_MINOR NUMERIC(20, 0)," - " STATUS VARCHAR(100)," - " CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING'))" + " STATUS VARCHAR(100)" ");" "CREATE TABLE ADMIN_USER(" " ADMIN_USER_NAME VARCHAR(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL," diff --git a/catalogue/CatalogueMetadataGetter.cpp b/catalogue/CatalogueMetadataGetter.cpp index 73ddce624d02d1a9b8058fd8031dfda07e650366..ba354d30488dab5f83f3ba2be0f25fab9bdd4c33 100644 --- a/catalogue/CatalogueMetadataGetter.cpp +++ b/catalogue/CatalogueMetadataGetter.cpp @@ -22,7 +22,10 @@ namespace cta { namespace catalogue { -void CatalogueMetadataGetter::removeObjectNameContaining(std::list<std::string>& objects, const std::list<std::string> &wordsToTriggerRemoval){ + +MetadataGetter::~MetadataGetter(){} + +void MetadataGetter::removeObjectNameContaining(std::list<std::string>& objects, const std::list<std::string> &wordsToTriggerRemoval){ objects.remove_if([&wordsToTriggerRemoval](const std::string &object){ return std::find_if(wordsToTriggerRemoval.begin(), wordsToTriggerRemoval.end(),[&object](const std::string &wordTriggeringRemoval){ return object.find(wordTriggeringRemoval) != std::string::npos; @@ -30,7 +33,7 @@ void CatalogueMetadataGetter::removeObjectNameContaining(std::list<std::string>& }); } -void CatalogueMetadataGetter::removeObjectNameNotContaining(std::list<std::string>& objects, const std::list<std::string> &wordsNotToTriggerRemoval){ +void MetadataGetter::removeObjectNameNotContaining(std::list<std::string>& objects, const std::list<std::string> &wordsNotToTriggerRemoval){ objects.remove_if([&wordsNotToTriggerRemoval](const std::string &object){ return std::find_if(wordsNotToTriggerRemoval.begin(), wordsNotToTriggerRemoval.end(),[&object](const std::string &wordsNotToTriggeringRemoval){ return object.find(wordsNotToTriggeringRemoval) == std::string::npos; @@ -38,13 +41,13 @@ void CatalogueMetadataGetter::removeObjectNameNotContaining(std::list<std::strin }); } -void CatalogueMetadataGetter::removeObjectNameNotMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex){ +void MetadataGetter::removeObjectNameNotMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex){ objects.remove_if([®ex](const std::string &object){ return !regex.has_match(object); }); } -void CatalogueMetadataGetter::removeObjectNameMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex){ +void MetadataGetter::removeObjectNameMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex){ objects.remove_if([®ex](const std::string &object){ return regex.has_match(object); }); @@ -93,7 +96,10 @@ std::map<std::string,std::string> CatalogueMetadataGetter::getColumns(const std: } std::list<std::string> CatalogueMetadataGetter::getConstraintNames(const std::string &tableName){ - return m_conn.getConstraintNames(tableName); + std::list<std::string> constraintNames = m_conn.getConstraintNames(tableName); + //This constraint is added by ALTER TABLE, we can't check its existence for now + removeObjectNameContaining(constraintNames,{"CATALOGUE_STATUS_CONTENT_CK"}); + return constraintNames; } CatalogueMetadataGetter::~CatalogueMetadataGetter() {} @@ -115,14 +121,6 @@ std::list<std::string> SQLiteCatalogueMetadataGetter::getTableNames(){ return tableNames; } -std::list<std::string> SQLiteCatalogueMetadataGetter::getConstraintNames(const std::string &tableName, cta::rdbms::Login::DbType dbType){ - std::list<std::string> constraintNames = CatalogueMetadataGetter::getConstraintNames(tableName); - if(dbType == cta::rdbms::Login::DbType::DBTYPE_POSTGRESQL){ - removeObjectNameMatches(constraintNames,cta::utils::Regex("(^NN_)|(_NN$)")); - } - return constraintNames; -} - OracleCatalogueMetadataGetter::OracleCatalogueMetadataGetter(cta::rdbms::Conn & conn):CatalogueMetadataGetter(conn){} OracleCatalogueMetadataGetter::~OracleCatalogueMetadataGetter(){} @@ -149,5 +147,33 @@ CatalogueMetadataGetter * CatalogueMetadataGetterFactory::create(const rdbms::Lo } } +/** + * SCHEMA METADATA GETTER methods + */ +SchemaMetadataGetter::SchemaMetadataGetter(std::unique_ptr<SQLiteCatalogueMetadataGetter> sqliteCatalogueMetadataGetter, const cta::rdbms::Login::DbType dbType):m_dbType(dbType) { + m_sqliteCatalogueMetadataGetter = std::move(sqliteCatalogueMetadataGetter); +} + +std::list<std::string> SchemaMetadataGetter::getIndexNames() { + return m_sqliteCatalogueMetadataGetter->getIndexNames(); +} + +std::list<std::string> SchemaMetadataGetter::getTableNames() { + return m_sqliteCatalogueMetadataGetter->getTableNames(); +} + +std::map<std::string,std::string> SchemaMetadataGetter::getColumns(const std::string& tableName) { + return m_sqliteCatalogueMetadataGetter->getColumns(tableName); +} + +std::list<std::string> SchemaMetadataGetter::getConstraintNames(const std::string& tableName) { + std::list<std::string> constraintNames = m_sqliteCatalogueMetadataGetter->getConstraintNames(tableName); + if(m_dbType == cta::rdbms::Login::DbType::DBTYPE_POSTGRESQL){ + //If the database to compare is POSTGRESQL, we cannot compare NOT NULL CONSTRAINT names + //indeed, POSTGRESQL can not give the NOT NULL constraint names + removeObjectNameMatches(constraintNames,cta::utils::Regex("(^NN_)|(_NN$)")); + } + return constraintNames; +} }} \ No newline at end of file diff --git a/catalogue/CatalogueMetadataGetter.hpp b/catalogue/CatalogueMetadataGetter.hpp index d2f77567bf015814c612e7fb1cc71f9e301613b2..dc8fcd1d9dc5be13b7ca40cb91d4e4c5b7bd688a 100644 --- a/catalogue/CatalogueMetadataGetter.hpp +++ b/catalogue/CatalogueMetadataGetter.hpp @@ -25,18 +25,32 @@ namespace cta { namespace catalogue { + +/** + * Interface class to get database metadata + */ +class MetadataGetter{ + +protected: + void removeObjectNameContaining(std::list<std::string>& objects, const std::list<std::string> &wordsToTriggerRemoval); + void removeObjectNameNotContaining(std::list<std::string>& objects, const std::list<std::string> &wordsNotToTriggerRemoval); + void removeObjectNameNotMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex); + void removeObjectNameMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex); +public: + virtual std::list<std::string> getIndexNames() = 0; + virtual std::list<std::string> getTableNames() = 0; + virtual std::map<std::string,std::string> getColumns(const std::string& tableName) = 0; + virtual std::list<std::string> getConstraintNames(const std::string& tableName) = 0; + virtual ~MetadataGetter() = 0; +}; /** * This class is used to get the Metadata (table names, columns, indexes) of the database accessed via the connection given in parameters * It will simply call the methods from the connection (Conn) instance and adapt or not the metadata returned. */ -class CatalogueMetadataGetter { +class CatalogueMetadataGetter: public MetadataGetter { protected: rdbms::Conn& m_conn; - void removeObjectNameContaining(std::list<std::string>& objects, const std::list<std::string> &wordsToTriggerRemoval); - void removeObjectNameNotContaining(std::list<std::string>& objects, const std::list<std::string> &wordsNotToTriggerRemoval); - void removeObjectNameNotMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex); - void removeObjectNameMatches(std::list<std::string> &objects, const cta::utils::Regex ®ex); public: CatalogueMetadataGetter(cta::rdbms::Conn & conn); virtual ~CatalogueMetadataGetter(); @@ -56,13 +70,6 @@ public: virtual ~SQLiteCatalogueMetadataGetter(); std::list<std::string> getIndexNames() override; std::list<std::string> getTableNames() override; - /** - * Get the constraint names but filters the result to be compatible with the database type passed in parameter - * @param tableName the table for which we want the constraint - * @param dbType the database type for which the results will be compatible - * @return the constraint names filtered in order to be compatible with the database type passed in parameter - */ - std::list<std::string> getConstraintNames(const std::string &tableName, cta::rdbms::Login::DbType dbType); }; /** @@ -103,4 +110,20 @@ public: static CatalogueMetadataGetter* create(const rdbms::Login::DbType dbType, cta::rdbms::Conn & conn); }; +/** + * This class is used to filter the Metadata that comes from the SQLite schema regarding the dbType we are currently checking + */ +class SchemaMetadataGetter: public MetadataGetter{ +protected: + std::unique_ptr<SQLiteCatalogueMetadataGetter> m_sqliteCatalogueMetadataGetter; + //The database type we would like to compare the SQLite schema against (used for filtering the results) + cta::rdbms::Login::DbType m_dbType; +public: + SchemaMetadataGetter(std::unique_ptr<SQLiteCatalogueMetadataGetter> sqliteCatalogueMetadataGetter, const cta::rdbms::Login::DbType dbType); + virtual std::list<std::string> getIndexNames() override; + virtual std::list<std::string> getTableNames() override; + virtual std::map<std::string,std::string> getColumns(const std::string& tableName) override; + virtual std::list<std::string> getConstraintNames(const std::string& tableName) override; +}; + }} \ No newline at end of file diff --git a/catalogue/SQLiteSchemaComparer.cpp b/catalogue/SQLiteSchemaComparer.cpp index f7f9b1a5786801fc0d81615603fa85c9e2ff1b19..c4c19a3488d3e032ed9ac2fc79a057edf43693da 100644 --- a/catalogue/SQLiteSchemaComparer.cpp +++ b/catalogue/SQLiteSchemaComparer.cpp @@ -28,9 +28,13 @@ namespace catalogue { SQLiteSchemaComparer::SQLiteSchemaComparer(const cta::rdbms::Login::DbType &catalogueDbType, rdbms::Conn &catalogueConn): SchemaComparer(catalogueDbType,catalogueConn) { log::DummyLogger dl("dummy","dummy"); auto login = rdbms::Login::parseString("in_memory"); + //Create SQLite connection m_sqliteConnPool.reset(new rdbms::ConnPool(login,1)); m_sqliteConn = std::move(m_sqliteConnPool->getConn()); - m_sqliteSchemaMetadataGetter.reset(new SQLiteCatalogueMetadataGetter(m_sqliteConn)); + //Create the Metadata getter + std::unique_ptr<SQLiteCatalogueMetadataGetter> sqliteCatalogueMetadataGetter(new SQLiteCatalogueMetadataGetter(m_sqliteConn)); + //Create the Schema Metadata Getter that will filter the SQLite schema metadata according to the catalogue database type we would like to compare + m_schemaMetadataGetter.reset(new SchemaMetadataGetter(std::move(sqliteCatalogueMetadataGetter),catalogueDbType)); } SQLiteSchemaComparer::~SQLiteSchemaComparer() { @@ -50,7 +54,7 @@ SchemaComparerResult SQLiteSchemaComparer::compareAll(){ SchemaComparerResult SQLiteSchemaComparer::compareTables(){ insertSchemaInSQLite(); std::list<std::string> catalogueTables = m_catalogueMetadataGetter->getTableNames(); - std::list<std::string> schemaTables = m_sqliteSchemaMetadataGetter->getTableNames(); + std::list<std::string> schemaTables = m_schemaMetadataGetter->getTableNames(); SchemaComparerResult res = compareTables(catalogueTables,schemaTables); return res; } @@ -70,7 +74,7 @@ void SQLiteSchemaComparer::insertSchemaInSQLite() { SchemaComparerResult SQLiteSchemaComparer::compareIndexes(){ insertSchemaInSQLite(); std::list<std::string> catalogueIndexes = m_catalogueMetadataGetter->getIndexNames(); - std::list<std::string> schemaIndexes = m_sqliteSchemaMetadataGetter->getIndexNames(); + std::list<std::string> schemaIndexes = m_schemaMetadataGetter->getIndexNames(); return compareItems("INDEX", catalogueIndexes, schemaIndexes); } @@ -102,9 +106,9 @@ SchemaComparerResult SQLiteSchemaComparer::compareTables(const std::list<std::st } for(auto &schemaTable: schemaTables){ - schemaTableColumns[schemaTable] = m_sqliteSchemaMetadataGetter->getColumns(schemaTable); + schemaTableColumns[schemaTable] = m_schemaMetadataGetter->getColumns(schemaTable); if(m_compareTableConstraints) { - schemaTableConstraints[schemaTable] = m_sqliteSchemaMetadataGetter->getConstraintNames(schemaTable,m_dbType); + schemaTableConstraints[schemaTable] = m_schemaMetadataGetter->getConstraintNames(schemaTable); result += compareItems("IN TABLE "+schemaTable+", CONSTRAINT",catalogueTableConstraints[schemaTable],schemaTableConstraints[schemaTable]); } } diff --git a/catalogue/SQLiteSchemaComparer.hpp b/catalogue/SQLiteSchemaComparer.hpp index 06a325dd310e3d46caac6b1f3c7f57705c5268f2..f08d381c297ac5a9cceab831360bb9ba5a79808c 100644 --- a/catalogue/SQLiteSchemaComparer.hpp +++ b/catalogue/SQLiteSchemaComparer.hpp @@ -51,7 +51,7 @@ private: SchemaComparerResult compareTableColumns(const TableColumns & schema1TableColumns, const std::string &schema1Type,const TableColumns & schema2TableColumns, const std::string &schema2Type); rdbms::Conn m_sqliteConn; std::unique_ptr<rdbms::ConnPool> m_sqliteConnPool; - std::unique_ptr<SQLiteCatalogueMetadataGetter> m_sqliteSchemaMetadataGetter; + std::unique_ptr<SchemaMetadataGetter> m_schemaMetadataGetter; bool m_isSchemaInserted = false; }; diff --git a/catalogue/common_catalogue_schema.sql b/catalogue/common_catalogue_schema.sql index 5e52a161a7fbf4db3cd0514474a204d27fd2dd7d..e53299c994469ded4c6ec8884e209e386fb89acd 100644 --- a/catalogue/common_catalogue_schema.sql +++ b/catalogue/common_catalogue_schema.sql @@ -3,8 +3,7 @@ CREATE TABLE CTA_CATALOGUE( SCHEMA_VERSION_MINOR UINT64TYPE CONSTRAINT CTA_CATALOGUE_SVM2_NN NOT NULL, NEXT_SCHEMA_VERSION_MAJOR UINT64TYPE, NEXT_SCHEMA_VERSION_MINOR UINT64TYPE, - STATUS VARCHAR(100), - CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING')) + STATUS VARCHAR(100) ); CREATE TABLE ADMIN_USER( ADMIN_USER_NAME VARCHAR(100) CONSTRAINT ADMIN_USER_AUN_NN NOT NULL, diff --git a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql index 8bca6adc7c1dc4dc9796e1138fe164c7d723c154..a6bd689d71ec0b2367e0e6cd76304d23bb72bb17 100644 --- a/catalogue/migrations/liquibase/oracle/1.0to1.1.sql +++ b/catalogue/migrations/liquibase/oracle/1.0to1.1.sql @@ -17,7 +17,7 @@ ADD ( --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 CTA_CATALOGUE ADD CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (STATUS='UPGRADING')); +ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (NEXT_SCHEMA_VERSION_MAJOR IS NOT NULL AND NEXT_SCHEMA_VERSION_MINOR IS NOT NULL AND STATUS='UPGRADING')) INITIALLY DEFERRED; --rollback ALTER TABLE CTA_CATALOGUE DROP CONSTRAINT CATALOGUE_STATUS_CONTENT_CK; --changeset ccaffy:3 failOnError:true dbms:oracle diff --git a/catalogue/oracle_catalogue_schema_trailer.sql b/catalogue/oracle_catalogue_schema_trailer.sql index 87ef767444198f9f726259786db121a8e2f5b6ea..1ae83ac443f2aa82e7b105c8ba63c3dd5eab1230 100644 --- a/catalogue/oracle_catalogue_schema_trailer.sql +++ b/catalogue/oracle_catalogue_schema_trailer.sql @@ -1 +1,3 @@ +ALTER TABLE CTA_CATALOGUE ADD CONSTRAINT CATALOGUE_STATUS_CONTENT_CK CHECK((NEXT_SCHEMA_VERSION_MAJOR IS NULL AND NEXT_SCHEMA_VERSION_MINOR IS NULL AND STATUS='COMPLETE') OR (NEXT_SCHEMA_VERSION_MAJOR IS NOT NULL AND NEXT_SCHEMA_VERSION_MINOR IS NOT NULL AND STATUS='UPGRADING')) INITIALLY DEFERRED; + COMMIT;