generated from digitalservicebund/java-application-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM cgr.dev/chainguard/wolfi-base:latest | ||
|
||
RUN apk update \ | ||
&& apk add --no-cache --update-cache postgresql-14-client; | ||
|
||
COPY src/import_from_migration.sql /import_from_migration.sql | ||
COPY --chmod=111 src/import_from_migration.sh /import_from_migration.sh | ||
|
||
CMD ["/import_from_migration.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
echo "MIGRATION_STATS_SCHEMA=$MIGRATION_STATS_SCHEMA" | ||
|
||
LATEST_SUCCESSFUL_RUN="$(psql --tuples-only --csv --command="SELECT created_at FROM $MIGRATION_STATS_SCHEMA.migration_stats ORDER BY created_at DESC LIMIT 1")" | ||
LATEST_SUCCESSFUL_RUN_DATE="${LATEST_SUCCESSFUL_RUN:0:10}" | ||
|
||
CURRENT_DATE="$(date "+%Y-%m-%d")" | ||
|
||
if [[ "$LATEST_SUCCESSFUL_RUN_DATE" != "$CURRENT_DATE" ]]; then | ||
echo "NORMS_SCHEMA=$NORMS_SCHEMA" | ||
echo "MIGRATION_SCHEMA=$MIGRATION_SCHEMA" | ||
psql --echo-all --variable=NORMS_SCHEMA=$NORMS_SCHEMA --variable=MIGRATION_SCHEMA=$MIGRATION_SCHEMA --file=./import_from_migration.sql | ||
else | ||
echo "Found no successful migration that finished today. Last successful run date: $LATEST_SUCCESSFUL_RUN. Today: $CURRENT_DATE" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
DELETE FROM :NORMS_SCHEMA.announcements; | ||
DELETE FROM :NORMS_SCHEMA.norms; | ||
|
||
INSERT INTO :NORMS_SCHEMA.norms (xml) SELECT ldml_xml.content FROM :MIGRATION_SCHEMA.migration_record | ||
INNER JOIN :MIGRATION_SCHEMA.ldml ldml ON migration_record.id = ldml.migration_record_id | ||
INNER JOIN :MIGRATION_SCHEMA.ldml_xml ldml_xml ON ldml.id = ldml_xml.ldml_id | ||
LEFT OUTER JOIN :MIGRATION_SCHEMA.migration_error migration_error on migration_record.id = migration_error.migration_record_id | ||
WHERE | ||
migration_status = 'LEGALDOCML_TRANSFORMATION_SUCCEEDED' | ||
AND xpath_exists('//akn:act[@name="regelungstext"]', ldml_xml.content, '{{akn,http://Inhaltsdaten.LegalDocML.de/1.7/}}') | ||
AND migration_error.id IS NULL; |