diff --git a/catalogue/1.1/mysql_catalogue_schema.sql b/catalogue/1.1/mysql_catalogue_schema.sql index ba96bfbb6c78be1d68b6532d7661bbdadf72a1c9..1b308e9b6c62e84441a653cb7494941a992955b7 100644 --- a/catalogue/1.1/mysql_catalogue_schema.sql +++ b/catalogue/1.1/mysql_catalogue_schema.sql @@ -288,7 +288,11 @@ CREATE TABLE EXPERIMENTS ( ); INSERT INTO CTA_CATALOGUE( SCHEMA_VERSION_MAJOR, - SCHEMA_VERSION_MINOR) + SCHEMA_VERSION_MINOR, + STATUS) VALUES( 1, - 1); + 1, + 'COMPLETE'); +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')); \ No newline at end of file diff --git a/catalogue/1.1/oracle_catalogue_schema.sql b/catalogue/1.1/oracle_catalogue_schema.sql index 14e458c836e70c764f52ce6ffb33b76fd5abe6af..3cdc5b282342c0d4f346267c730a5bd6743d1902 100644 --- a/catalogue/1.1/oracle_catalogue_schema.sql +++ b/catalogue/1.1/oracle_catalogue_schema.sql @@ -310,10 +310,12 @@ CREATE TABLE EXPERIMENTS ( ); INSERT INTO CTA_CATALOGUE( SCHEMA_VERSION_MAJOR, - SCHEMA_VERSION_MINOR) + SCHEMA_VERSION_MINOR, + STATUS) VALUES( 1, - 1); + 1, + 'COMPLETE'); 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 662305e2cdd3cb0cbaf0eea095d6857d733e4bdf..b27719df47724c3c75ec9fd6728d735c6de3a711 100644 --- a/catalogue/1.1/postgres_catalogue_schema.sql +++ b/catalogue/1.1/postgres_catalogue_schema.sql @@ -295,11 +295,15 @@ CREATE TABLE EXPERIMENTS ( ); INSERT INTO CTA_CATALOGUE( SCHEMA_VERSION_MAJOR, - SCHEMA_VERSION_MINOR) + SCHEMA_VERSION_MINOR, + STATUS) VALUES( 1, - 1); + 1, + 'COMPLETE'); ALTER TABLE ARCHIVE_FILE DROP CONSTRAINT ARCHIVE_FILE_DIN_DFI_UN; ALTER TABLE ARCHIVE_FILE ADD CONSTRAINT ARCHIVE_FILE_DIN_DFI_UN UNIQUE(DISK_INSTANCE_NAME, DISK_FILE_ID) DEFERRABLE INITIALLY IMMEDIATE; +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')); diff --git a/catalogue/1.1/sqlite_catalogue_schema.sql b/catalogue/1.1/sqlite_catalogue_schema.sql index b730593c347fe5074544217b5b1e9301c5a36e81..820520416257f1d6633eae7fdc9d3fc1f9518f59 100644 --- a/catalogue/1.1/sqlite_catalogue_schema.sql +++ b/catalogue/1.1/sqlite_catalogue_schema.sql @@ -279,7 +279,9 @@ CREATE TABLE EXPERIMENTS ( ); INSERT INTO CTA_CATALOGUE( SCHEMA_VERSION_MAJOR, - SCHEMA_VERSION_MINOR) + SCHEMA_VERSION_MINOR, + STATUS) VALUES( 1, - 1); + 1, + 'COMPLETE'); diff --git a/catalogue/AllCatalogueSchema.hpp b/catalogue/AllCatalogueSchema.hpp index d3e567a99bca6d26c79f122860e57bb853791b98..51f560dd3406b4d1473c93b03d1ad8cca3b4a9ec 100644 --- a/catalogue/AllCatalogueSchema.hpp +++ b/catalogue/AllCatalogueSchema.hpp @@ -1535,10 +1535,12 @@ namespace catalogue{ ");" "INSERT INTO CTA_CATALOGUE(" " SCHEMA_VERSION_MAJOR," - " SCHEMA_VERSION_MINOR)" + " SCHEMA_VERSION_MINOR," + " STATUS)" "VALUES(" " 1," - " 1);" + " 1," + " 'COMPLETE');" "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;" @@ -1833,10 +1835,14 @@ namespace catalogue{ ");" "INSERT INTO CTA_CATALOGUE(" " SCHEMA_VERSION_MAJOR," - " SCHEMA_VERSION_MINOR)" + " SCHEMA_VERSION_MINOR," + " STATUS)" "VALUES(" " 1," - " 1);" + " 1," + " 'COMPLETE');" + "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'));" }, {"sqlite", "CREATE TABLE ARCHIVE_FILE_ID(" " ID INTEGER PRIMARY KEY AUTOINCREMENT" @@ -2119,10 +2125,12 @@ namespace catalogue{ ");" "INSERT INTO CTA_CATALOGUE(" " SCHEMA_VERSION_MAJOR," - " SCHEMA_VERSION_MINOR)" + " SCHEMA_VERSION_MINOR," + " STATUS)" "VALUES(" " 1," - " 1);" + " 1," + " 'COMPLETE');" }, {"postgres", "CREATE SEQUENCE ARCHIVE_FILE_ID_SEQ" " INCREMENT BY 1" @@ -2421,14 +2429,18 @@ namespace catalogue{ ");" "INSERT INTO CTA_CATALOGUE(" " SCHEMA_VERSION_MAJOR," - " SCHEMA_VERSION_MINOR)" + " SCHEMA_VERSION_MINOR," + " STATUS)" "VALUES(" " 1," - " 1);" + " 1," + " 'COMPLETE');" "ALTER TABLE ARCHIVE_FILE DROP CONSTRAINT" " ARCHIVE_FILE_DIN_DFI_UN;" "ALTER TABLE ARCHIVE_FILE ADD CONSTRAINT" " ARCHIVE_FILE_DIN_DFI_UN UNIQUE(DISK_INSTANCE_NAME, DISK_FILE_ID) DEFERRABLE INITIALLY IMMEDIATE;" + "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'));" }, } },}; diff --git a/catalogue/CMakeLists.txt b/catalogue/CMakeLists.txt index dc310f54fe7537bbb397da443b579e42f6c4a1ba..4776686a9c930d1b9255859eeab3a4ad88cc2ba2 100644 --- a/catalogue/CMakeLists.txt +++ b/catalogue/CMakeLists.txt @@ -165,6 +165,7 @@ add_custom_command (OUTPUT sqlite_catalogue_schema.sql mysql_catalogue_schema.sq ${CMAKE_CURRENT_SOURCE_DIR}/oracle_catalogue_schema_trailer.sql ${CMAKE_CURRENT_SOURCE_DIR}/CreateAllSchemasCppFile.sh ${CMAKE_CURRENT_SOURCE_DIR}/AllCatalogueSchema.hpp.in + ${CMAKE_CURRENT_SOURCE_DIR}/insert_cta_catalogue_version.sql.in ) add_custom_command(OUTPUT sqlite_catalogue_schema.cpp diff --git a/catalogue/insert_cta_catalogue_version.sql.in b/catalogue/insert_cta_catalogue_version.sql.in index 22d3d0b3a8bc22bc8d261e41d7a76af413920f27..644a112b425e765a4791a1aeaeb83a72e9b0116d 100644 --- a/catalogue/insert_cta_catalogue_version.sql.in +++ b/catalogue/insert_cta_catalogue_version.sql.in @@ -1,6 +1,8 @@ INSERT INTO CTA_CATALOGUE( SCHEMA_VERSION_MAJOR, - SCHEMA_VERSION_MINOR) + SCHEMA_VERSION_MINOR, + STATUS) VALUES( @CTA_CATALOGUE_SCHEMA_VERSION_MAJOR@, - @CTA_CATALOGUE_SCHEMA_VERSION_MINOR@); \ No newline at end of file + @CTA_CATALOGUE_SCHEMA_VERSION_MINOR@, + 'COMPLETE'); \ No newline at end of file diff --git a/catalogue/mysql_catalogue_schema_trailer.sql b/catalogue/mysql_catalogue_schema_trailer.sql index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..297849c8f7d84dc42ff17bd10764272988ddd96c 100644 --- a/catalogue/mysql_catalogue_schema_trailer.sql +++ b/catalogue/mysql_catalogue_schema_trailer.sql @@ -0,0 +1,2 @@ +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')); \ No newline at end of file diff --git a/catalogue/postgres_catalogue_schema_trailer.sql b/catalogue/postgres_catalogue_schema_trailer.sql index 02931d98022756729cb725de9525f392488c7599..991527176c55bba4f1236aeef1592e580cadb6f0 100644 --- a/catalogue/postgres_catalogue_schema_trailer.sql +++ b/catalogue/postgres_catalogue_schema_trailer.sql @@ -2,3 +2,5 @@ ALTER TABLE ARCHIVE_FILE DROP CONSTRAINT ARCHIVE_FILE_DIN_DFI_UN; ALTER TABLE ARCHIVE_FILE ADD CONSTRAINT ARCHIVE_FILE_DIN_DFI_UN UNIQUE(DISK_INSTANCE_NAME, DISK_FILE_ID) DEFERRABLE INITIALLY IMMEDIATE; +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'));