Skip to content

Commit

Permalink
Cndit 584 (#66)
Browse files Browse the repository at this point in the history
* CNDIT-584 Adding Liquibase to Gradle build. Upgrading Gradle to latest

* Introducing Liquibase

CNDIT-584 Introducing Liquibase
  • Loading branch information
sdeusch authored Sep 25, 2023
1 parent 7f6538c commit 2bd11fb
Show file tree
Hide file tree
Showing 27 changed files with 164 additions and 56 deletions.
Binary file added .gradle/6.7.1/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/6.7.1/fileHashes/fileHashes.lock
Binary file not shown.
Empty file added .gradle/6.7.1/gc.properties
Empty file.
Binary file added .gradle/8.3/checksums/checksums.lock
Binary file not shown.
Binary file added .gradle/8.3/checksums/md5-checksums.bin
Binary file not shown.
Binary file added .gradle/8.3/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Empty file.
Binary file not shown.
Binary file added .gradle/8.3/executionHistory/executionHistory.lock
Binary file not shown.
Binary file added .gradle/8.3/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/8.3/fileHashes/fileHashes.bin
Binary file not shown.
Binary file added .gradle/8.3/fileHashes/fileHashes.lock
Binary file not shown.
Binary file added .gradle/8.3/fileHashes/resourceHashesCache.bin
Binary file not shown.
Empty file added .gradle/8.3/gc.properties
Empty file.
Binary file added .gradle/checksums/checksums.lock
Binary file not shown.
Empty file.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
42 changes: 40 additions & 2 deletions report-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
classpath "org.liquibase:liquibase-gradle-plugin:2.2.0"
}
}

Expand All @@ -16,16 +20,29 @@ plugins {
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'jacoco'
id "org.sonarqube" version "4.2.1.3168"
id 'org.liquibase.gradle' version '2.2.0'
// id 'checkstyle'
}



group = 'gov.cdc.dataingestion'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'
java {
sourceCompatibility = JavaVersion.VERSION_17
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

tasks.withType(Jar).all { duplicatesStrategy = DuplicatesStrategy.EXCLUDE }

if ( isReleaseVersion ) {
println "using staging"
ext.mavenCentralUploadUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
} else {
println "using snapshot"
ext.mavenCentralUploadUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
}

configurations {
jaxb
compileOnly {
Expand All @@ -34,6 +51,7 @@ configurations {
}

repositories {
mavenLocal()
mavenCentral()
}

Expand Down Expand Up @@ -159,8 +177,14 @@ dependencies {
// Only need below two dependencies for java code generation from xsd file(s)
jaxb 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
jaxb 'org.glassfish.jaxb:jaxb-xjc:4.0.2'

// Liquibase
liquibaseRuntime 'org.liquibase:liquibase-core:4.3.1'
liquibaseRuntime group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
liquibaseRuntime 'com.microsoft.sqlserver:mssql-jdbc:12.2.0.jre11'
}


test {
useJUnitPlatform()
}
Expand All @@ -179,4 +203,18 @@ sonarqube {
property "sonar.organization", "cdcgov"
property "sonar.host.url", "https://sonarcloud.io"
}
}
}


apply plugin: "org.liquibase.gradle"

liquibase {
activities {
main {
changelogFile './src/main/resources/db/changelog.xml'
url "jdbc:sqlserver://${System.env.DI_DBSERVER};databaseName=${System.env.DI_DBNAME};encrypt=true;trustServerCertificate=true"
username "${System.env.DI_USERNAME}"
password "${System.env.DI_PASSWORD}"
}
}
}
10 changes: 0 additions & 10 deletions report-service/sql-script/clients.sql

This file was deleted.

13 changes: 0 additions & 13 deletions report-service/sql-script/elr_dlt.sql

This file was deleted.

9 changes: 0 additions & 9 deletions report-service/sql-script/elr_fhir.sql

This file was deleted.

9 changes: 0 additions & 9 deletions report-service/sql-script/elr_raw.sql

This file was deleted.

12 changes: 0 additions & 12 deletions report-service/sql-script/elr_validated.sql

This file was deleted.

16 changes: 16 additions & 0 deletions report-service/src/main/resources/db/changelog.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd">

<changeSet id="1" author="liquibase">
<sqlFile path="src/main/resources/db/report-service-001.sql" />
</changeSet>

</databaseChangeLog>
76 changes: 76 additions & 0 deletions report-service/src/main/resources/db/report-service-001.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

-- changeset liquibase:1
--
-- Creates the tables used by Data Ingestion Service
--
CREATE TABLE elr_raw (
id uniqueidentifier DEFAULT newid() NOT NULL,
message_type nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
payload ntext COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
updated_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_on datetime DEFAULT getdate() NOT NULL,
updated_on datetime NULL,
CONSTRAINT PK__elr_raw__3213E83F108B8188 PRIMARY KEY (id)
);


CREATE TABLE elr_validated (
id uniqueidentifier DEFAULT newid() NOT NULL,
raw_message_id uniqueidentifier NULL,
message_type nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
message_version nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
validated_message ntext COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
updated_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_on datetime DEFAULT getdate() NOT NULL,
updated_on datetime NULL,
hashed_hl7_string varchar(64) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
CONSTRAINT PK__elr_vali__3213E83FBDBA6B93 PRIMARY KEY (id)
);

ALTER TABLE elr_validated ADD CONSTRAINT FK__elr_valid__raw_i__5FB337D6 FOREIGN KEY (raw_message_id) REFERENCES elr_raw(id);


CREATE TABLE elr_fhir (
id uniqueidentifier DEFAULT newid() NOT NULL,
fhir_message nvarchar COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
raw_message_id uniqueidentifier NULL,
created_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
updated_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_on datetime DEFAULT getdate() NOT NULL,
updated_on datetime NULL,
CONSTRAINT PK__elr_fhir__3213E83FC8183E1D PRIMARY KEY (id)
);

ALTER TABLE elr_fhir ADD CONSTRAINT FK__elr_fhir__raw_me__5AEE82B9 FOREIGN KEY (raw_message_id) REFERENCES elr_raw(id);


CREATE TABLE elr_dlt (
error_message_id uniqueidentifier NOT NULL,
error_message_source nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
error_stack_trace nvarchar COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
error_stack_trace_short nvarchar COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
dlt_status nvarchar(10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
dlt_occurrence int NULL,
message ntext COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
updated_by nvarchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_on datetime DEFAULT getdate() NOT NULL,
updated_on datetime NULL,
CONSTRAINT PK__elr_dlt__CCC56D623E5B71D2 PRIMARY KEY (error_message_id)
);


CREATE TABLE clients (
id uniqueidentifier DEFAULT newid() NOT NULL,
client_id varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
client_secret varchar(512) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
client_roles varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
created_by varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
updated_by varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
created_on datetime DEFAULT getdate() NOT NULL,
updated_on datetime NULL,
CONSTRAINT PK__clients__3213E83F1D101DC2 PRIMARY KEY (id),
CONSTRAINT UQ__clients__BF21A425ECA9C5BB UNIQUE (client_id)
);
31 changes: 31 additions & 0 deletions report-service/src/main/resources/dlt-logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<configuration>
<!-- Appenders -->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
</appender>

<appender name="DYNAMIC_FILE" class="gov.cdc.dataingestion.config.LogDynamicFileAppenderConfig">
<logFilePath>logs/kafka_dlt_error-%d{yyyy-MM-dd}.log</logFilePath>
<append>true</append>
<encoder class="net.logstash.logback.encoder.LogstashEncoder" />
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>logs/kafka_dlt_error-%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>30</maxHistory> <!-- Number of old log files to keep -->
<totalSizeCap>1GB</totalSizeCap> <!-- Maximum total size of log files -->
</rollingPolicy>
</appender>

<!-- Loggers -->
<logger name="gov.cdc.dataingestion.kafka.integration.service.KafkaConsumerService" level="INFO">
<appender-ref ref="DYNAMIC_FILE" />
</logger>

<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

0 comments on commit 2bd11fb

Please sign in to comment.