Skip to content

Commit

Permalink
Cnde 2104 - Liquibase for DI, MSGOUTE (ECR) and consolidate Data Sync…
Browse files Browse the repository at this point in the history
… to use change log (#136)

Co-authored-by: [email protected] <[email protected]>
  • Loading branch information
ndduc01 and alog-enquizit authored Jan 20, 2025
1 parent 97d67e7 commit 7252b45
Show file tree
Hide file tree
Showing 18 changed files with 1,102 additions and 416 deletions.
11 changes: 11 additions & 0 deletions liquibase-service/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,30 @@ RUN wget "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -O "awscliv2


#Copy sources
#changelog
COPY liquibase-service/src/main/resources/db/changelog /liquibase/changelog
#master
COPY liquibase-service/src/main/resources/db/master /liquibase/changelog
COPY liquibase-service/src/main/resources/db/master/routines /liquibase/changelog
#odse
COPY liquibase-service/src/main/resources/db/odse /liquibase/changelog
COPY liquibase-service/src/main/resources/db/odse/routines /liquibase/changelog
COPY liquibase-service/src/main/resources/db/odse/views /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb_modern /liquibase/changelog
#rdb_modern
COPY liquibase-service/src/main/resources/db/rdb_modern/routines /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb_modern/tables /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb_modern/views /liquibase/changelog
#rdb
COPY liquibase-service/src/main/resources/db/rdb /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb/routines /liquibase/changelog
COPY liquibase-service/src/main/resources/db/rdb/tables /liquibase/changelog
# data_ingest
COPY liquibase-service/src/main/resources/db/data_ingest /liquibase/changelog
COPY liquibase-service/src/main/resources/db/data_ingest/tables /liquibase/changelog
# msgoute
COPY liquibase-service/src/main/resources/db/msgoute /liquibase/changelog
COPY liquibase-service/src/main/resources/db/msgoute/routines /liquibase/changelog

#Set the Working Directory
WORKDIR /liquibase/changelog
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
databaseChangeLog:
- changeSet:
id: 0
author: liquibase
changes:
- sqlFile:
path: 000-dataingest-db-general-001.sql
splitStatements: false
- changeSet:
id: 1
author: liquibase
changes:
- sqlFile:
path: 001-create_data_ingest_table-001.sql
splitStatements: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
databaseChangeLog:
- changeSet:
id: 0
author: liquibase
changes:
- sqlFile:
path: 000-msgoute-db-general-001.sql
splitStatements: false
- changeSet:
id: 1
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: 001-alter_nbs_interface-001.sql
splitStatements: false
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ databaseChangeLog:
author: liquibase
changes:
- sqlFile:
path: 000-db-general-001.sql
path: 000-odse-db-general-001.sql
splitStatements: false
- changeSet:
id: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ databaseChangeLog:
author: liquibase
changes:
- sqlFile:
path: 000-db-general-001.sql
path: 000-rdb-db-general-001.sql
splitStatements: false
- changeSet:
id: 1
Expand All @@ -16,35 +16,8 @@ databaseChangeLog:
- changeSet:
id: 2
author: liquibase
runOnChange: true
changes:
- sqlFile:
path: 001-generate_data_for_data_sync_config-001.sql
splitStatements: false
- changeSet:
id: 3
author: liquibase
changes:
- sqlFile:
path: 001-generate_data_for_data_sync_config-002.sql
splitStatements: false
- changeSet:
id: 4
author: liquibase
changes:
- sqlFile:
path: 001-generate_data_for_data_sync_config-003.sql
splitStatements: false
- changeSet:
id: 5
author: liquibase
changes:
- sqlFile:
path: 001-generate_data_for_data_sync_config-004.sql
splitStatements: false
- changeSet:
id: 6
author: liquibase
changes:
- sqlFile:
path: 001-generate_data_for_data_sync_config-005.sql
splitStatements: false
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ databaseChangeLog:
author: liquibase
changes:
- sqlFile:
path: 000-db-general-001.sql
path: 000-rdbmodern-db-general-001.sql
splitStatements: false
- changeSet:
id: 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Upgrade compatibility level to allow inbuilt functions such as StringSplit
ALTER
DATABASE NBS_DataIngest SET COMPATIBILITY_LEVEL = 130;

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
IF
NOT EXISTS(
SELECT 'X'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'elr_raw')
BEGIN
CREATE TABLE elr_raw
(
id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
message_type NVARCHAR(255) NOT NULL,
payload NTEXT NOT NULL,
created_by NVARCHAR(255) NOT NULL,
updated_by NVARCHAR(255) NOT NULL,
created_on DATETIME NOT NULL DEFAULT getdate(),
updated_on DATETIME NULL
);
END

IF
NOT EXISTS(
SELECT 'X'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'elr_validated')
BEGIN
CREATE TABLE elr_validated
(
id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
raw_message_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES elr_raw (id),
message_type NVARCHAR(255) NOT NULL,
message_version NVARCHAR(255),
validated_message ntext NOT NULL,
hashed_hl7_string varchar(64) NULL,
created_by NVARCHAR(255) NOT NULL,
updated_by NVARCHAR(255) NOT NULL,
created_on DATETIME NOT NULL DEFAULT getdate(),
updated_on DATETIME NULL
);
END

IF
NOT EXISTS(
SELECT 'X'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'elr_dlt')
BEGIN
CREATE TABLE elr_dlt
(
error_message_id UNIQUEIDENTIFIER PRIMARY KEY,
error_message_source NVARCHAR(255) NOT NULL,
error_stack_trace NVARCHAR(MAX) NOT NULL,
error_stack_trace_short NVARCHAR(MAX) NOT NULL,
dlt_status NVARCHAR(10) NOT NULL,
dlt_occurrence INT,
message ntext NOT NULL,
created_by NVARCHAR(255) NOT NULL,
updated_by NVARCHAR(255) NOT NULL,
created_on DATETIME NOT NULL DEFAULT getdate(),
updated_on DATETIME NULL
);
END


IF
NOT EXISTS(
SELECT 'X'
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'elr_record_status_id')
BEGIN
CREATE TABLE elr_record_status_id
(
id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID(),
raw_message_id UNIQUEIDENTIFIER FOREIGN KEY REFERENCES elr_raw (id),
nbs_interface_id NVARCHAR(255) NOT NULL,
created_by NVARCHAR(255) NOT NULL,
updated_by NVARCHAR(255) NOT NULL,
created_on DATETIME NOT NULL DEFAULT getdate(),
updated_on DATETIME NULL
);
END
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
IF
EXISTS (SELECT 1 FROM sysobjects WHERE name = 'NBS_interface' and xtype = 'U')
BEGIN

IF
NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'original_payload_RR' AND Object_ID = Object_ID(N'NBS_interface'))
BEGIN
ALTER TABLE dbo.NBS_interface
ADD original_payload_RR TEXT;
END;

IF
NOT EXISTS(SELECT 1 FROM sys.columns WHERE name = N'original_doc_type_cd_RR' AND Object_ID = Object_ID(N'NBS_interface'))
BEGIN
ALTER TABLE dbo.NBS_interface
ADD original_doc_type_cd_RR varchar(100);
END;
END;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Upgrade compatibility level to allow inbuilt functions such as StringSplit
ALTER
DATABASE RDB SET COMPATIBILITY_LEVEL = 130;

Loading

0 comments on commit 7252b45

Please sign in to comment.