diff --git a/db/upgrade/odse/000-odse-db-general.sql b/db/upgrade/odse/000-odse-db-general.sql index 8d327f7e..1f7d2110 100644 --- a/db/upgrade/odse/000-odse-db-general.sql +++ b/db/upgrade/odse/000-odse-db-general.sql @@ -1,3 +1,2 @@ -- Upgrade compatibility level to allow inbuilt functions such as StringSplit ALTER DATABASE NBS_ODSE SET COMPATIBILITY_LEVEL = 130; - diff --git a/db/upgrade/srte/000-srte-db-general.sql b/db/upgrade/srte/000-srte-db-general.sql index 36937c96..4e94c683 100644 --- a/db/upgrade/srte/000-srte-db-general.sql +++ b/db/upgrade/srte/000-srte-db-general.sql @@ -1,2 +1,2 @@ -- Upgrade compatibility level to allow inbuilt functions such as StringSplit -ALTER DATABASE NBS_SRTE SET COMPATIBILITY_LEVEL = 130; \ No newline at end of file +ALTER DATABASE NBS_SRTE SET COMPATIBILITY_LEVEL = 130; diff --git a/liquibase-service/src/main/resources/db/changelog/db.odse.admin.tasks.changelog-16.1.yaml b/liquibase-service/src/main/resources/db/changelog/db.odse.admin.tasks.changelog-16.1.yaml new file mode 100644 index 00000000..1534a75c --- /dev/null +++ b/liquibase-service/src/main/resources/db/changelog/db.odse.admin.tasks.changelog-16.1.yaml @@ -0,0 +1,10 @@ +databaseChangeLog: + - changeSet: + id: 0 + author: liquibase + runOnChange: true + comment: "Enable CDC for Treatment table in ODSE" + changes: + - sqlFile: + path: 000-odse-db-general-001.sql + splitStatements: false \ No newline at end of file diff --git a/liquibase-service/src/main/resources/db/odse/000-odse-db-general-001.sql b/liquibase-service/src/main/resources/db/odse/000-odse-db-general-001.sql index 8d327f7e..283fc314 100644 --- a/liquibase-service/src/main/resources/db/odse/000-odse-db-general-001.sql +++ b/liquibase-service/src/main/resources/db/odse/000-odse-db-general-001.sql @@ -1,3 +1,11 @@ -- Upgrade compatibility level to allow inbuilt functions such as StringSplit ALTER DATABASE NBS_ODSE SET COMPATIBILITY_LEVEL = 130; +-- Check if Treatment table exists and CDC is not enabled, then enable CDC +if not exists( + SELECT 1 + FROM sys.tables + WHERE name = 'Treatment' and is_tracked_by_cdc = 1) + begin + exec sys.sp_cdc_enable_table @source_schema = N'dbo',@source_name = N'Treatment',@role_name = NULL; + end; \ No newline at end of file diff --git a/liquibase-service/src/main/resources/db/srte/000-srte-db-general-001.sql b/liquibase-service/src/main/resources/db/srte/000-srte-db-general-001.sql index 36937c96..4e94c683 100644 --- a/liquibase-service/src/main/resources/db/srte/000-srte-db-general-001.sql +++ b/liquibase-service/src/main/resources/db/srte/000-srte-db-general-001.sql @@ -1,2 +1,2 @@ -- Upgrade compatibility level to allow inbuilt functions such as StringSplit -ALTER DATABASE NBS_SRTE SET COMPATIBILITY_LEVEL = 130; \ No newline at end of file +ALTER DATABASE NBS_SRTE SET COMPATIBILITY_LEVEL = 130;