From 229683dfa57f30f215f7105a41d3b943fb635c0f Mon Sep 17 00:00:00 2001 From: Tomi Eckert Date: Wed, 24 Sep 2025 22:03:52 +0200 Subject: [PATCH] feat(aurora): Dynamically fetch and update company name in refreshed schema Enhances 'aurora.sh' to fetch the original company name from the source schema and use it to construct a descriptive company name for the new Aurora schema (e.g., "AURORA - [Original Name] - [Date]"). Updates script version to 2.1.0. --- aurora/aurora.sh | 23 +++++++++++++++-------- packages.conf | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/aurora/aurora.sh b/aurora/aurora.sh index 4990d17..de84ef9 100644 --- a/aurora/aurora.sh +++ b/aurora/aurora.sh @@ -1,7 +1,5 @@ #!/bin/sh -# Version: 2.0.0 -# -# Aurora Refresh Script v2.1 +# Version: 2.1.0 # # Purpose: Performs an automated refresh of a SAP HANA schema. It exports a # production schema and re-imports it under a new name ("Aurora") @@ -68,10 +66,22 @@ echo " -> Import complete." # 5. Update company name in CINF and OADM tables. echo "✍️ Updating company name fields in the new schema..." + +# First, get the original company name from the source schema. +# The query returns a header and the name in quotes. sed gets the second line, tr removes the quotes, xargs trims whitespace. +echo " -> Fetching original company name from '${SOURCE_SCHEMA}'..." +ORIGINAL_COMPNY_NAME=$("$HDBSQL" -U "$DB_ADMIN_KEY" "SELECT \"CompnyName\" FROM \"${SOURCE_SCHEMA}\".\"CINF\"" | sed -n '2p' | tr -d '"' | xargs) + +# Construct the new name in the desired format. +DATE_STAMP=$(date "+%Y-%m-%d") +NEW_COMPNY_NAME="AURORA - ${ORIGINAL_COMPNY_NAME} - ${DATE_STAMP}" +echo " -> New company name set to: '${NEW_COMPNY_NAME}'" + echo " -> Updating CINF table..." -"$HDBSQL" -U "$DB_ADMIN_KEY" "UPDATE \"${AURORA_SCHEMA}\".CINF SET \"CompnyName\" = 'AURORA ${COMPANY_NAME_BASE} ${TIMESTAMP}';" >/dev/null +"$HDBSQL" -U "$DB_ADMIN_KEY" "UPDATE \"${AURORA_SCHEMA}\".CINF SET \"CompnyName\" = '${NEW_COMPNY_NAME}';" >/dev/null + echo " -> Updating OADM table..." -"$HDBSQL" -U "$DB_ADMIN_KEY" "UPDATE \"${AURORA_SCHEMA}\".OADM SET \"CompnyName\" = 'AURORA ${COMPANY_NAME_BASE} ${TIMESTAMP}', \"PrintHeadr\" = 'AURORA ${COMPANY_NAME_BASE} ${TIMESTAMP}';" >/dev/null +"$HDBSQL" -U "$DB_ADMIN_KEY" "UPDATE \"${AURORA_SCHEMA}\".OADM SET \"CompnyName\" = '${NEW_COMPNY_NAME}', \"PrintHeadr\" = '${NEW_COMPNY_NAME}';" >/dev/null echo " -> Company info updated." # 6. Grant privileges to the read/write user. @@ -107,6 +117,3 @@ echo "✅ [$(date "+%T")] Aurora Refresh finished successfully!" echo exit 0 - - - diff --git a/packages.conf b/packages.conf index ef331d2..f9e3c33 100644 --- a/packages.conf +++ b/packages.conf @@ -7,7 +7,7 @@ declare -A SCRIPT_PACKAGES # The version should match the "# Version: x.x.x" line in the main script file. -SCRIPT_PACKAGES["Aurora Suite"]="2.0.0|https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.conf" +SCRIPT_PACKAGES["Aurora Suite"]="2.1.0|https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/aurora/aurora.conf" SCRIPT_PACKAGES["Backup Suite"]="1.0.5|https://git.technopunk.space/tomi/Scripts/raw/branch/main/backup/backup.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/backup/backup.conf" SCRIPT_PACKAGES["Monitor Suite"]="1.0.5|https://git.technopunk.space/tomi/Scripts/raw/branch/main/monitor/monitor.sh https://git.technopunk.space/tomi/Scripts/raw/branch/main/monitor/monitor.conf" SCRIPT_PACKAGES["Key Manager"]="1.2.1|https://git.technopunk.space/tomi/Scripts/raw/branch/main/hdb_keymanager.sh"