Skip to content

Commit

Permalink
Update function name get_current_date to get_current_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jvasquezrojas committed Feb 27, 2024
1 parent 0c44ae8 commit 00fef04
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions Teradata/bin/create_ddls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ include_objects="(UPPER(T1.TABLENAME) LIKE ANY ('%'))"
##### CONSTANTS
steps="5"

function get_current_date
function get_current_timestamp
{
date '+%Y/%m/%d %l:%M:%S%p'
}

echo "[$(get_current_date)] Info: Step 1/${steps} - Creating Directories: Started"
echo "[$(get_current_timestamp)] Info: Step 1/${steps} - Creating Directories: Started"
mkdir -p ../log
mkdir -p ../temp
mkdir -p ../output
mkdir -p ../output/object_extracts
mkdir -p ../output/object_extracts/DDL
cp -r ../scripts_template ../scripts
touch -- "../output/object_extracts/DDL/.sc_extracted"
echo "[$(get_current_date)] Info: Step 1/${steps} - Creating Directories: Completed"
echo "[$(get_current_timestamp)] Info: Step 1/${steps} - Creating Directories: Completed"


echo "[$(get_current_date)] Info: Step 2/${steps} - Extracting DDLs: Started"
echo "[$(get_current_timestamp)] Info: Step 2/${steps} - Extracting DDLs: Started"
declare -a scripts_file=(
[0]="create_databases"
[1]="create_functions"
Expand All @@ -71,45 +71,45 @@ declare -a scripts_name=(


for i in "${!scripts_file[@]}"; do
echo "[$(get_current_date)] Info: Start extracting ${scripts_name[$i]}"
echo "[$(get_current_timestamp)] Info: Start extracting ${scripts_name[$i]}"

if [[ ! -f ../scripts/"${scripts_file[$i]}".btq ]]
then
echo "[$(get_current_date)] ERROR: file ${scripts_file[$i]} not found"
echo "[$(get_current_timestamp)] ERROR: file ${scripts_file[$i]} not found"
fi
sed -i "s|include_databases|$include_databases|g" ../scripts/"${scripts_file[$i]}".btq
sed -i "s|exclude_databases|$exclude_databases|g" ../scripts/"${scripts_file[$i]}".btq
sed -i "s|include_objects|$include_objects|g" ../scripts/"${scripts_file[$i]}".btq
sed -i "s|connection_string|$connection_string|g" ../scripts/"${scripts_file[$i]}".btq
bteq <../scripts/"${scripts_file[$i]}".btq >../log/${scripts_file[$i]}.log 2>&1

echo "[$(get_current_date)] Info: Extracted ${scripts_name[$i]}"
echo "[$(get_current_timestamp)] Info: Extracted ${scripts_name[$i]}"

done
echo "[$(get_current_date)] Info: Step 2/${steps} - Extracting DDLs: Completed"
echo "[$(get_current_timestamp)] Info: Step 2/${steps} - Extracting DDLs: Completed"


echo "[$(get_current_date)] Info: Step 3/${steps} - Removing unnecessary comments: Started"
echo "[$(get_current_timestamp)] Info: Step 3/${steps} - Removing unnecessary comments: Started"
[[ ! -f ../output/object_extracts/DDL/DDL_Tables.sql ]] || sed -i "s|--------------.*--------------||g" ../output/object_extracts/DDL/DDL_Tables.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Join_Indexes.sql ]] || sed -i "s|--------------.*--------------||g" ../output/object_extracts/DDL/DDL_Join_Indexes.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Views.sql ]] || sed -i "s|--------------.*--------------||g" ../output/object_extracts/DDL/DDL_Views.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Functions.sql ]] || sed -i "s|--------------.*--------------||g" ../output/object_extracts/DDL/DDL_Functions.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Macros.sql ]] || sed -i "s|--------------.*--------------||g" ../output/object_extracts/DDL/DDL_Macros.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Procedures.sql ]] || sed -i "s|--------------.*--------------||g" ../output/object_extracts/DDL/DDL_Procedures.sql
[[ ! -f ../output/object_extracts/DDL/DDL_SF_Schemas.sql ]] || sed -i "s| |\n|g" ../output/object_extracts/DDL/DDL_SF_Schemas.sql
echo "[$(get_current_date)] Info: Step 3/${steps} - Removing unnecessary comments: Completed"
echo "[$(get_current_timestamp)] Info: Step 3/${steps} - Removing unnecessary comments: Completed"

echo "[$(get_current_date)] Info: Step 4/${steps} - Replacing unicode values: Started"
echo "[$(get_current_timestamp)] Info: Step 4/${steps} - Replacing unicode values: Started"
[[ ! -f ../output/object_extracts/DDL/DDL_Tables.sql ]] || sed -i -e "s|\U2013|-|g" -e "s|\U00D8|0|g" -e "s|\U00A0| |g" -e "s|\U1680| |g" -e "s|\U180E| |g" -e "s|\U2000| |g" -e "s|\U2001| |g" -e "s|\U2002| |g" -e "s|\U2003| |g" -e "s|\U2004| |g" -e "s|\U2005| |g" -e "s|\U2006| |g" -e "s|\U2007| |g" -e "s|\U2008| |g" -e "s|\U2009| |g" -e "s|\U200A| |g" -e "s|\U200B| |g" -e "s|\U202F| |g" -e "s|\U205F| |g" -e "s|\U3000| |g" -e "s|\UFEFF| |g" ../output/object_extracts/DDL/DDL_Tables.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Join_Indexes.sql ]] || sed -i -e "s|\U2013|-|g" -e "s|\U00D8|0|g" -e "s|\U00A0| |g" -e "s|\U1680| |g" -e "s|\U180E| |g" -e "s|\U2000| |g" -e "s|\U2001| |g" -e "s|\U2002| |g" -e "s|\U2003| |g" -e "s|\U2004| |g" -e "s|\U2005| |g" -e "s|\U2006| |g" -e "s|\U2007| |g" -e "s|\U2008| |g" -e "s|\U2009| |g" -e "s|\U200A| |g" -e "s|\U200B| |g" -e "s|\U202F| |g" -e "s|\U205F| |g" -e "s|\U3000| |g" -e "s|\UFEFF| |g" ../output/object_extracts/DDL/DDL_Join_Indexes.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Views.sql ]] || sed -i -e "s|\U2013|-|g" -e "s|\U00D8|0|g" -e "s|\U00A0| |g" -e "s|\U1680| |g" -e "s|\U180E| |g" -e "s|\U2000| |g" -e "s|\U2001| |g" -e "s|\U2002| |g" -e "s|\U2003| |g" -e "s|\U2004| |g" -e "s|\U2005| |g" -e "s|\U2006| |g" -e "s|\U2007| |g" -e "s|\U2008| |g" -e "s|\U2009| |g" -e "s|\U200A| |g" -e "s|\U200B| |g" -e "s|\U202F| |g" -e "s|\U205F| |g" -e "s|\U3000| |g" -e "s|\UFEFF| |g" ../output/object_extracts/DDL/DDL_Views.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Functions.sql ]] || sed -i -e "s|\U2013|-|g" -e "s|\U00D8|0|g" -e "s|\U00A0| |g" -e "s|\U1680| |g" -e "s|\U180E| |g" -e "s|\U2000| |g" -e "s|\U2001| |g" -e "s|\U2002| |g" -e "s|\U2003| |g" -e "s|\U2004| |g" -e "s|\U2005| |g" -e "s|\U2006| |g" -e "s|\U2007| |g" -e "s|\U2008| |g" -e "s|\U2009| |g" -e "s|\U200A| |g" -e "s|\U200B| |g" -e "s|\U202F| |g" -e "s|\U205F| |g" -e "s|\U3000| |g" -e "s|\UFEFF| |g" ../output/object_extracts/DDL/DDL_Functions.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Macros.sql ]] || sed -i -e "s|\U2013|-|g" -e "s|\U00D8|0|g" -e "s|\U00A0| |g" -e "s|\U1680| |g" -e "s|\U180E| |g" -e "s|\U2000| |g" -e "s|\U2001| |g" -e "s|\U2002| |g" -e "s|\U2003| |g" -e "s|\U2004| |g" -e "s|\U2005| |g" -e "s|\U2006| |g" -e "s|\U2007| |g" -e "s|\U2008| |g" -e "s|\U2009| |g" -e "s|\U200A| |g" -e "s|\U200B| |g" -e "s|\U202F| |g" -e "s|\U205F| |g" -e "s|\U3000| |g" -e "s|\UFEFF| |g" ../output/object_extracts/DDL/DDL_Macros.sql
[[ ! -f ../output/object_extracts/DDL/DDL_Procedures.sql ]] || sed -i -e "s|\U2013|-|g" -e "s|\U00D8|0|g" -e "s|\U00A0| |g" -e "s|\U1680| |g" -e "s|\U180E| |g" -e "s|\U2000| |g" -e "s|\U2001| |g" -e "s|\U2002| |g" -e "s|\U2003| |g" -e "s|\U2004| |g" -e "s|\U2005| |g" -e "s|\U2006| |g" -e "s|\U2007| |g" -e "s|\U2008| |g" -e "s|\U2009| |g" -e "s|\U200A| |g" -e "s|\U200B| |g" -e "s|\U202F| |g" -e "s|\U205F| |g" -e "s|\U3000| |g" -e "s|\UFEFF| |g" ../output/object_extracts/DDL/DDL_Procedures.sql
echo "[$(get_current_date)] Info: Step 4/${steps} - Replacing unicode values: Completed"
echo "[$(get_current_timestamp)] Info: Step 4/${steps} - Replacing unicode values: Completed"

echo "[$(get_current_date)] Info: Step 5/${steps} - Removing temporal files: Started"
echo "[$(get_current_timestamp)] Info: Step 5/${steps} - Removing temporal files: Started"
rm -r ../temp
rm -r ../scripts

echo "[$(get_current_date)] Info: Step 5/${steps} - Removing temporal files: Completed"
echo "[$(get_current_timestamp)] Info: Step 5/${steps} - Removing temporal files: Completed"

0 comments on commit 00fef04

Please sign in to comment.